JSP - Applet communication
Using servlets it is possible to setup a Servlet-Applet (or a Servlet-client
application in general) communication through http-post messages. Is there
anyway to do simular things with JSP, or is a Servlet still the preferred
way of setting up HTTP-post mechanisms?
Re: JSP - Applet communication
In article <email@example.com>, Jo Desmet <firstname.lastname@example.org> wrote:
>Using servlets it is possible to setup a Servlet-Applet (or a Servlet-client
>application in general) communication through http-post messages. Is there
>anyway to do simular things with JSP, or is a Servlet still the preferred
>way of setting up HTTP-post mechanisms?
The good news is that since JSPs are automatically converted into
servlets, anything you can do in one you can do in the other. In fact
there are several ways you can handle this sort of communication in a
If your applet is sending form-like data (that is, name/value pairs
separated by ampersands) then you can just use beans to receive these
values directly. So, if your applet sends something like
"animal=fish&color=gold", and you have a bean named handler that has
setAnimal() and setColor() methods, then you can just include this in
<jsp:setProperty name="handler" property="*">
and everything will just work. Beans are cool...
Alternately, if your applet is sending some arbitrary data you can
handle it much as in a servlet. In a servlet you might do something
InputStream in = request.getInputStream();
StringBuffer buffy = new StringBuffer();
byte data = new byte;
while((count = in.read(data)) > 0)
String postdata = buffy.toString();
You can do the same thing in a JSP by enclosing all of the above in a
<java></java> block. You could then send postdata to a bean with a
setPostdata() method. Or, you could move all of the above code into a
bean, and send the whole request to the bean with something like:
<jsp:setValue name="bean" property="request"
value="<%= request %>">
This is probably the cleanest option, at least for those building
pages. In either case, once the bean has the data, it can do whatever
it needs to with it, and then make other properties available to the
rest of the page.
Hope this helped!
By Rey Morejon in forum Java
Last Post: 03-30-2008, 02:03 AM
By Gautham Kasinath in forum Java
Last Post: 04-14-2006, 03:52 PM
By Charlie Flynn in forum Java
Last Post: 08-23-2001, 11:01 AM
Last Post: 08-10-2000, 12:35 PM
Last Post: 08-10-2000, 12:33 PM
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL