Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HTTP Servlet

 
ramya ray
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A HTTP Servlet extended from javax.servlet.http.HttpServlet

a) Override the service method
b) Override the doGet method or/and doPost() method
c) Override the init method
d) Override the startUp method

The answer given for this is - a whereas i think it should be b.

Thanks,
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Servlet extended from HttpServlet can also override service() method but then it has to specify its own functionality to call doGet/doPut/doPost etc depending upon the request type.

It can also override doGet/doPost directly and it can also override init()/init(ServletConfig) methods

So i guess a,b,c options can be correct

The statment of question is confusing
 
ramya ray
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right Ali the statement is confusing.
So if we look at it as an Application developer we will only override doGet()... methods only as other methods are meant to be leave as it in most of the cases.

Also i think if we are extending our servlet from GenericServlet then we have to override of service() method whereas in HTTPServelt its not.

Thanks,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic