Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet Objects  RSS feed

 
karthick janaki
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any one explain wht happens exactly in the below coding :

public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
doGet(request, response);
}
--------------
Thanks in advance
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. Basically the doGet method is being used to handle both POSTS and GETs. Saves you writing the code twice.
 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The container calls the appropriate service method based on the http method in the request it receives (i.e. doPost() for a POST, doGet() for a GET...). In your code, if a call is made to the doPost() method, it, in turn, calls the doGet() method. This is done when you want your servlet to do the same thing regardless of whether it is called by a POST or a GET request.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!