wood burning stoves 2.0*
The moose likes Servlets and the fly likes doGet,doPost 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 » Servlets
Bookmark "doGet,doPost" Watch "doGet,doPost" New topic
Author

doGet,doPost

rex tony
Ranch Hand

Joined: Aug 29, 2007
Posts: 159
what is the difference between
doGet()
{
doPost()
}
,
doPost()
{
doGet()
}
in servlet?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

What is the diffence between

and

? Can you imagine why you would prefer one rather that the other ?


[My Blog]
All roads lead to JavaRanch
rex tony
Ranch Hand

Joined: Aug 29, 2007
Posts: 159
Hello Verre,
In servlet life cycle we have doGet,doPost methods in which some time i've seen some programmers calling like this
doGet(req,res)
{
doPost(req,res)
}

,

doPost(req,res)
{
doGet(req,res)
}

Is there any technical reason to call like this?
Give me a brief explanation.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Is there any technical reason to call like this?

No, there's no technical reason for that, except what was explained by other ranchers in your other post. Most of the time, you'll do the same thing in doGet and doPost, so one trick is to put your logic in one of both. The other one just calls the one containing the code. In this case, it doesn't matter whether you put it in doPost or in doGet.

is the same as

What the whole thing means is : do the same useful thing whether the request is a GET or a POST
You could even do it like
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: doGet,doPost
 
Similar Threads
is servlet doGet and doPost method are threadsafe?
what is the difference between doGet and doPost?
Servlet - second assignment
doPost and doGet
POST or GET