• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

APPLET ,Servlet Communication

 
Dean Jones
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
can u tell me how a applet can call a servlet using the post method
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi dean,
i tried to do the same stuff once. i ended up POSTing the data the way i wanted but the problem was to retrieve the result.
to post data to the servlet u can,
-get URLConnection to the servelt,
-get it's output stream,
-gather all parameters u want to POST,
-encode those parameters in querystring format (encoding using URLEncoder.encode method)
-and write this parameter string to the URLConnection's output stream...
here u r done with POSTing. u can recieve the result of the servlet by getting URLConnection's inputstream but when i tried all these i couldn't make my browser displaying the result. i still wonder if we can do that....
so, if u just want some text/plain info as a result of post and u don't need to display anything to the user then above method works.
ELSE i dont know
here is the code i used to do above,
(I GOT THIS CODE FROM ORIELLY'S BOOK-Java Servlets)

anybody have solution to my problem of displaying result back in the browser???
regards
maulin.
 
meera sood
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi!
you can always have an outstream back to the applet, write the data to this output stream, retrieve this in the applet, using an input stream and display the message back in the applet. i was also stuck with the same problem and this is the way out i found. if somebody has a better solution, do let us know
meera
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic