can we override service method in my servlet class..?? if
yes or no why ??
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
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 |
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 |
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 |
Can we override the ActionServlet?
3 Answers ArisGlobal, HCL, PPF,
Is there any differance b/w getting servlet context from servlet config and session? if yes then what is that?
how the server will know its the same jsp page?
Why do we use sendredirect() method?
In which cases Destroy() is invoked?
How many ways are available to ger RequestDispatcher object?
What is the first statement in jsp page.
What is meant by session? Tell me something about httpsession class?
What are the different methods of session management in servlets?
What if you need to span your transaction across multiple servlet invocations?
which type of data passing is used in realtime?
What are the types of an http request?