It's not a secret anymore!*
The moose likes Servlets and the fly likes overriding service() method in HttpServlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "overriding service() method in HttpServlet" Watch "overriding service() method in HttpServlet" New topic
Author

overriding service() method in HttpServlet

amarjeet kumar
Greenhorn

Joined: Oct 21, 2006
Posts: 2
if we extend Httpservlet in our servlet program then as i know do...() method is used which in turn extends service()method implicitly.But i have made a program in which service() method has been overloaded in HttpServlet.Can anyone tell me how it works Please.

thanks
amar
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

If you don't understand the implications of overriding service(), why would you do it?

And with regards to:

as i know do...() method is used which in turn extends service()method implicitly


Overloading any of the doXXX() methods does not "implicitly extend" service(), whatever "implicitly extend" means.
[ October 22, 2006: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Originally posted by amarjeet kumar:
if we extend Httpservlet in our servlet program then as i know do...() method is used which in turn extends service()method implicitly.But i have made a program in which service() method has been overloaded in HttpServlet.


service method is the one which delegates the call to the respective doXXXX method accroding to the request.getMethod().So in case you override the service method the delegation is not taking place and you code is getting executed and the results you are positive.


Rahul Bhattacharjee
LinkedIn - Blog
Durgaprasad
Greenhorn

Joined: Oct 02, 2006
Posts: 17
the sequesnce is

firstly, service(ServletRequest,ServletRespone) will be called which in turn calls service(HttpServletRequest,HttpServletResponse) which based on the type of the method(Get,Post etc..) will call the appropriate doXXX() method
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Durgaprasad,
Welcome to JavaRanch!

We're pleased to have you here with us in the servlets forum, but there
are a few rules that need to be followed, and one is that proper names are
required. Please take a look at the
JavaRanch Naming Policy and
adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

You can change it here
[ October 25, 2006: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: overriding service() method in HttpServlet
 
Similar Threads
which service() method is called
service() method
how call the doGet method
service() method in GenericServlet & HttpServlet
how many methods are called???