• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling a Servlet from an Applet

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I pass things (parameters,strings,...) from an applet to a Servlet?.
I'm connected from the Applet to the Servlet with its URL.I get URL's OutputStream and send a string.
In the Servlet I'm trying to read the sended string with the ReadLine() method but the servlet don't run good. It waits for something to read that never arrives.
Thanks.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is an example of an applet calling a servlet by passing it an object and then getting an object back from the servlet. The rule is the objects passed back and forth must be serializable. So you could pass a String containing a SQL statement from the applet to the servlet and get back a Vector (not a ResultSet which isn't serializable) from the servlet.
This example is very simple. All the applet does is pass an object to the servlet which adds 10 to an int inside the object and then passes the object back again.
Here is the class passed back and forth:

Here is the applet.

Here is the servlet:


[This message has been edited by Thomas Paul (edited February 28, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic