*
The moose likes Java in General and the fly likes how to post data from applet to servlet. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to post data from applet to servlet." Watch "how to post data from applet to servlet." New topic
Author

how to post data from applet to servlet.

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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

Joined: Nov 18, 2000
Posts: 110
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

Joined: Nov 22, 2000
Posts: 3
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

Joined: Dec 01, 2000
Posts: 44
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
 
 
subject: how to post data from applet to servlet.
 
Similar Threads
HTML Frames / Applet / Servlet and Session Tracking - Help with Strategy Please
print applet
How to call Servlet from Applet?
How to invoke servlet using JApplet
sending an e-mail