• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

servlet question

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Enthuware Software Support
Posts: 4810
52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 4810
52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic