• Post Reply Bookmark Topic Watch Topic
  • New Topic

servlet methods

 
Reshma Reddy
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi to all,
when we use both doGet() and doPost() methods in a java class, is there any real situations to use these methods,if so pls tell me what are that situations.

Thanks,
vishnu.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what you're asking here.
The doGet and doPost methods are the most commonly overridden methods in a servlet.

Let me turn the question around.
Why would YOU write a servlet?
What would it do?
To do this, what methods do you think you should override in your servlet?
 
Jaime M. Tovar
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you mean use both in the same call, I think the answer is no. The server will call a doGet when receives a get request, and a doPost in a post request. You can't receive both kinds of request in the same call.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A servlet may well react differently to GET and POST requests, so it does indeed make sense to have both of them in a servlet. This entry in the Servlets FAQ also deals with the subject.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!