File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes doGet and doPost method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "doGet and doPost method" Watch "doGet and doPost method" New topic

doGet and doPost method

felix thomas
Ranch Hand

Joined: Jun 10, 2001
Posts: 89
What is the advantage of calling doGet method from doPost method or vice versa.
Brahim Bakayoko
Ranch Hand

Joined: Aug 29, 2003
Posts: 155
The amount of data you can pass in.

GET requests are limited in most browsers to 256 characters.

All hrefs are GET and all forms are POST.

SCJP, SCWCD, SCBCD, IBM CSD WebSphere v5, <br />A+, MCP 2000 and 2000 server, CST, and few incompleted certification tracks.<br /> <br />Ivory Coast<br /> <br />Analyze your web Request/Response @ <a href="" target="_blank" rel="nofollow"></a> down for a while...
Scott Duncan
Ranch Hand

Joined: Nov 01, 2002
Posts: 364
Actually GET is default when nothing else is specified. So forms only submit to doPost if the method in the form is specified as such. Also GET is less secure since data is posted in the url....
[ July 01, 2004: Message edited by: William Duncan ]

No more rhymes! I mean it!<br /> <br />Does anybody want a peanut?
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

A frequent pattern that you will see is that the doGet method will call doPost or vice versa. This allows the serlvet to repsond to both GET and POST request in the exact same manner.

If your servlet needs to respond to these differently, then this pattern is not used.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: doGet and doPost method
jQuery in Action, 3rd edition