This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes override the service method in servlet 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 "override the service method in servlet" Watch "override the service method in servlet" New topic
Author

override the service method in servlet

PavanPL KalyanK
Ranch Hand

Joined: Feb 28, 2009
Posts: 212
I got a query while going through a tutorial on servlets

If i override the service method , do i need to explicitly call doGet() or doPost()?


could anybody please clarify the above one.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

To what purpose would you want to override service()?



[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
PavanPL KalyanK
Ranch Hand

Joined: Feb 28, 2009
Posts: 212
No reason , just wanted to know.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41155
    
  45
See http://faq.javaranch.com/java/ServletsFaq#overriding-service


Ping & DNS - my free Android networking tools app
PavanPL KalyanK
Ranch Hand

Joined: Feb 28, 2009
Posts: 212
Good point Ulf , but why do we need extra control on Http ?

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41155
    
  45
I'm not sure what you mean by "extra control". The HTTP extension mechanism is an IETF RFC; WebDAV uses it, and any day there could be other new extensions. Those can only be accommodated by overriding the service method, since the existing implementation couldn't possibly know about them.
PavanPL KalyanK
Ranch Hand

Joined: Feb 28, 2009
Posts: 212
You mean to say that i can override the service() and use HttpServlet class for other protocols other than HTTP.

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41155
    
  45
No. HTTPServlet is for HTTP only - hence its name. HTTP extensions are still based on HTTP, as the name implies.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: override the service method in servlet
 
Similar Threads
Service method
Confused about Life cycle of Servlets
overwriting service method
HTTP Servlet
overridding service()