File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Doubts in HTTP Methods behaviour Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Doubts in HTTP Methods behaviour" Watch "Doubts in HTTP Methods behaviour" New topic
Author

Doubts in HTTP Methods behaviour

Micheal John
Ranch Hand

Joined: Nov 01, 2006
Posts: 344


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 ]

Micheal John
SCJP 1.4 (86%), SCWCD 1.4 (86%), SCBCD 1.3 (85%), SCDJWS (Just Started...) - Satisfaction Lies in Our EFFORT, Not in the ATTAINMENT
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

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.


SCJP 1.4, SCWCD 1.4 - Hints for you, SCBCD Hints - Demnachst, SCDJWS - Auch Demnachst
Did a rm -R / to find out that I lost my entire Linux installation!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39549
    
  27
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.


Ping & DNS - updated with new look and Ping home screen widget
Boobalan Jegathesan
Greenhorn

Joined: Jan 08, 2007
Posts: 17
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 ]

Thanks<br />Boobalan.(SCJP1.4)
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

I agree with you Jagatheesan!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubts in HTTP Methods behaviour
 
Similar Threads
Strange problem - request forwarding
servlet
Requested Dispatcher
Servlets example
Progress bar on IE6