Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


can we override service method in my servlet class..?? if
yes or no why ??

Answers were Sorted based on User's Feedback



can we override service method in my servlet class..?? if yes or no why ??..

Answer / ruchi

we can override service method in my servlet class if the
request is not protocol dependent.
Bcoz we exdend HttpSrevlet class to handle Http GET and
POST requests and we have to override some methods like
doGet,doPost,doHead,doPut,doDelete.

But if u want to override service method then u have to
extend genricServlet Class.Then only u can implement Service
() method.

Is This Answer Correct ?    52 Yes 8 No

can we override service method in my servlet class..?? if yes or no why ??..

Answer / sekhar babu

yes, we can override service() in our servlet, but not
preferable. if we want use these service from any protocol
like ftp,telnet, then we have to override.

Is This Answer Correct ?    36 Yes 6 No

can we override service method in my servlet class..?? if yes or no why ??..

Answer / rajesh

We can override Service method in the servlet when we extend GenericServlet to create servlet as it is mandatory to override it. But when we extend HttpServlet to create a servlet then we cant override service as we need to override doGet or doPost method of HttpServlet

Is This Answer Correct ?    17 Yes 6 No

can we override service method in my servlet class..?? if yes or no why ??..

Answer / ravikiran

no it's not a good practice to overide the service
method...if we call any of the doxxx method then internally
it will call the service method of the HttpServlet

Is This Answer Correct ?    13 Yes 3 No

can we override service method in my servlet class..?? if yes or no why ??..

Answer / manidhar

NO. Very unlikely.
You should NOT override the service()method. Your job is to
override the doGet()/doPost() methods and let the service()
implementaion form HTTPServlet worry about calling the
right one.

Is This Answer Correct ?    12 Yes 3 No

can we override service method in my servlet class..?? if yes or no why ??..

Answer / ravikiran

no it's not a good practice to overide the service
method...if we call any of the doxxx method then internally
it will call the service method of the HttpServlet

Is This Answer Correct ?    5 Yes 3 No

can we override service method in my servlet class..?? if yes or no why ??..

Answer / muzaffar

Yes, we can override service method. But then we have to give our own implementation to detect which type of method request is using.(i.e GET or POST). Since we mostly use HTTP as a protocol itz best to extend HTTPServlet and override doGET or doPOST accordingly.

Is This Answer Correct ?    2 Yes 3 No

Post New Answer

More Servlets Interview Questions

If we disable cookies in our web page, what will happen?

6 Answers   Zensar,


Can we refresh servlet in client and server side automatically?

0 Answers  


Explain the working of service() method of a servlet.

0 Answers  


What are the jobs performed by servlets?

0 Answers  


how to use servlets with j2ee ?

2 Answers   Tech Mahindra,


What is string tokenizer?

0 Answers  


What are the features added in Servlet 2.5?

0 Answers  


can servlet have instance variables?

8 Answers   Syscon, Wipro,


What do you mean by default initialization in java servlet?

0 Answers  


How we can check in particular page the session will be alive or not

4 Answers   L&T, Symbiosis,


How can we create deadlock situation in servlet?

0 Answers  


can it possible to validate form field before execution of a servlet service method if yes how??

6 Answers  


Categories