• 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

Doubts in HTTP Methods behaviour

 
Ranch Hand
Posts: 344
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Nothing is printing why? I thought of printing "This is doPost!".
But I am comment the service(), then it is printing as I expected.
My Doubts are:
1. Why when I override all service(), doPost() and doGet(), eventhough the form action is post is not landing in doPost()
2. Suppose If I am commenting the doPost() and doGet() and form's action is Post/Get, then it should land on service(), but it's not landing why?
3. What will be happen if the service() is calling the destory()?
[ January 23, 2007: Message edited by: Micheal John ]
 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Michael,

You are right. If you override service(), then you must specify which method to transfer control to. Remember that every thread starts with service(). However if you don't override service(), then the one in HttpServlet runs and since you have overridden the doPost(), it runs for the servlet class that you write.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should never need to override the service method, and you absolutely, positively, should not call the destroy (or init) method. Read through the javadocs for these methods for some more information.
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

If you see the implementation of service method ,there your request will be forwarded to either doGet , doPost ,doPut ....based on the httpMethod.

So if you override the service method programmer should take care to forward the request to appropriate doXXX methods.

just have a look at this url to know about the implementation of service method...

http://www.docjar.com/html/api/javax/servlet/http/HttpServlet.java.html

why do you want to override service method..?If you are developing webapp then doXXX methods will do process your requests.
[ January 23, 2007: Message edited by: Boobalan Jegathesan ]
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with you Jagatheesan!
reply
    Bookmark Topic Watch Topic
  • New Topic