*
The moose likes Servlets and the fly likes When a request is sent to the servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "When a request is sent to the servlet" Watch "When a request is sent to the servlet" New topic
Author

When a request is sent to the servlet

p hasini
Ranch Hand

Joined: Oct 24, 2009
Posts: 92
There is a servlet class which extends HttpServlet and has service() method and doGet() and doPost() methods defined.Which of the following methods get called when a request is sent for the servlet.

1. Only doGet()
2.Only doPost()
3.only service()
4.doGet() and then service()
5.service() and then doGet()
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

"p hl", please check your private messages for an important administrative matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

Looks like a homework question to me... what's your answer and why?
p hasini
Ranch Hand

Joined: Oct 24, 2009
Posts: 92
Actually this is an interview question asked.I dont know the correct reply.

I need the answer
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

p hasini wrote:I need the answer

What're your thoughts on it? JavaRanch is not an answer mill, it's a learning site.

Tell us what you think the answer is, and why, and then we can discuss it.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12676
    
    5
Reading the servlet API before interviewing for a servlet job is highly recommended.
Why not start here!

Bill


Java Resources at www.wbrogden.com
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: When a request is sent to the servlet
 
Similar Threads
Protected doGet/doPost service methods
please reply urgently!!!
Multi-threading in servlets
what is the reason for overriding the doGet() or doPost() method
servlets: can we override service method ?if yes how and why?if no then why?