Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Overriding service() method of HttpServlet class  RSS feed

 
Rachit Kumar Saxena
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens if I explicitly override service() method of HttpServlet class which calls doGet or doPost() method like:
public void service(HttpServletRequest request,HttpServletResponse response)
{
doGet(r,r2);
}
Will it still work?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65825
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unless you can write a 14-page dissertation on why you have a good reason to override service(), you should not.

And what you wrote doesn't "work". In fact it breaks the method rather badly. Aside from the fact that it won't even compile, that is.
 
Anurag Verma
Ranch Hand
Posts: 168
Hibernate Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In normal scenarios, we should never override service() method. I haven't faced any situation yet where i observed the need of overriding service() method. (At the same time i don't deny its not possible.)
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65825
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, as I said, it's possible, but shouldn't be done unless there's a really really good reason to do so, and that the ramifications of doing so are completely understood.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!