Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

applet to servlet communication

 
srinivas k
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
how can i invoke with a servlet using an applet so that only the doPost() method is only called (ofcourse besides other methods like init(), destroy() method are by default invoked) i:e i do not want doGet() method to be invoked when i call the servlet using an applet, i want the doPost() method to be invoked. :roll:
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Srinivas,
As far as I know, when you use the "java.net.URLConnection" class to connect to a servlet from another java class (like and applet, for example), you are invoking that servlet's "doPost()" method only (and _not_ its "doGet()" method).
In case you haven't read it, this article contains more details:
http://www.javaworld.com/javaworld/jw-03-2001/jw-0323-traps.html
Hope this helps.
Good Luck,
Avi.
 
srinivas k
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for ur reply Mr.Avi,
Even though we use URLConnection it invokes doGet() method only but not doPost() , i have tried this even
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then remove the query part of your URL -- this is the part after the question-mark, example:
http://www.some_site.org?id=321
The "?id=321" part causes the "doGet()" method of your servlet to be invoked. Remove that, and your servlet's "doPost()" method _should_ be invoked.
Hope this helps.
Good Luck,
Avi.
 
Marilyn de Queiroz
Sheriff
Posts: 9067
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, srinivas k..

Welcome to JavaRanch! Please adjust your display name to meet the JavaRanch Naming Policy. Unfortunately "k.." is not a valid last name. You can change it here.

Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic