This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doGet,doPost

 
rex tony
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the difference between
doGet()
{
doPost()
}
,
doPost()
{
doGet()
}
in servlet?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the diffence between

and

? Can you imagine why you would prefer one rather that the other ?
 
rex tony
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic