Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlet question

 
deepak kukreja
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
'm new to servlets.
Just know that there are methods named doXXX() and getXXX()
Could somebody tell me which case we use doGet() and in which we
use doPost().
One more method, service is availbale. If suppose I
send a 'get' request, which methods will be called? in which sequence
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3760
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, the names of the methods giveaway what should they be used for. doGet() for implementing GET request (for eg. clicking on a URL) and doPost() for POST requests (for eg. submitting a form).
You don't need to implement service(...) methods. GenericServlet and its subclass HttpServlet (from which you'll extend your servlet) implement them appropriately. The servlet container calls service(ServletRequest, ServletResponse). This method calls service(HttpServletRequest, HttpServletResponse), whic(implemented in HttpServlet), determines the request type (GET, POST, etc) and calls the respective method.
HTH,
Paul.
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3760
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BTW, you should read this stuff from http://www.amazon.com/exec/obidos/ASIN/1930110596/jdiscuss-20. It explains it very nicely from the exam point of view.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic