Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to post data from applet to servlet.

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to set up a simple mail server, when some one sign up i want a servlet to be invoked which give the form for a new user and when he log's in the mail box should open. but my confusion is how on the press of a button (ie and applet button)
while i perform this task. please me with this query. thanks .
 
Van Glass
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at using the URLConnection classes. You will need these to post your data. You may want to try using JHTTP 1.1 at http://www.jscape.com Handles most all HTTP related functionality.

------------------
JFind - Your Java Resource www.jfind.com
 
Senthil Nathan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Inside the Applet, u instantiate a URL object by passing the url of the servlet which is going to handle the request as a parameter. Invoke a method called open request on the URL object which would give u URLConnection Object. Using connection object, get input & output streams and then write into the stream the datas which u want to pass to the servlet.
I would give u the code (frame work)
URL url = new URL("servlet url");
URLConnection con = url.openConnection();
OutputStream out = con.getOutputStream();
out.write("date to be sent");
Does this clears ur doubt?
 
le taylom
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Applet to servlet communication is a great way (and more pure Java) to reproduce 2 components of the model-view-controller.
Take a look at the following article for a good overview, with code, on how to do it.
I won't repeat it by writing any more here!
http://www.j-nine.com/pubs/applet2servlet/Applet2Servlet.html
Good luck
T
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic