File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 61214
    
  66

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: 41861
    
  63
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: 41861
    
  63
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: 41861
    
  63
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