This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Modern JavaScript for the Impatient and have Cay Horstmann on-line!
See this thread for details.
Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Why service() cannot be overridden??

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why can't u override service() in HttpServletClass??HFS says never to override this method.....
but why not override this method so that the servlet will service any request from the client(irrespective of whether the request is get,post,put etc)....i have written code overriding the service method and it executed fine...
 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
service automatically chooses whether too use doget or dopost or something else. If you override it you have to call the methods yourself. any way you need dopost or doget to handle the requests. If not specified the servlet won't know what to do!!!
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sandhya,

as marco has indicated,
If you override service then you need to write the logic for calling the doPost and doGet in your servlet,
but because your requirement is regardless of doGet and doPost you want to execute teh same logic which you can achive by
doGet() // assume all the parameters are there
{
call doPost();
}
doPost()
{
your logic
}
by overriding service you cannot differentiate even the head,trace,options requests.
 
Yeah. What he said. Totally. Wait. What? Sorry, I was looking at this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic