What is the modifier for the HttpServlet class service method?

Protected.

Questions by sujatham   answers by sujatham

Showing Answers 1 - 27 of 27 Answers

fcasttro

  • Nov 21st, 2007
 

For HTTP its Protected
For Generic its Public

HTTP
-----
protected
void service(javax.servlet.http.HttpServletRequest httpservletrequest, javax.servlet.http.HttpServletResponse httpservletresponse)

Generic
--------

public abstract void service(javax.servlet.ServletRequest servletrequest, javax.servlet.ServletResponse servletresponse)

  Was this answer useful?  Yes

hemasundar

  • Jan 10th, 2008
 

which service method?
there are two service() methods in HTTPServlet
1. public void service(__ , __)      ---------> 1
2. protected void service(__ , __) --------> 2

Both methods take same type of request and response objects for their exection.
The first service method is LifeCycle method of the servlet. This method calls the second service method internally. Generally whenever we're writing the service method in servlets, we'll over ride the second service method (See the API docs for more info).

  Was this answer useful?  Yes

it_uday

  • Jul 31st, 2008
 

HttpServlet class extends the GenericServlet class.So it has two service methods.

(1) public void service(ServletRequest req,ServletResponce res);
(2) protected void service(HttpServletRequest req,HttpServletResponce res);

Thus the the  modifier for the HttpServlet class  service  method are-public and protected

  Was this answer useful?  Yes

delindia fathima

  • Dec 20th, 2011
 

We have two service methods in httpServlet

Dispatches client requests to the protected service method. Theres no need to override this method.
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {}

Receives standard HTTP requests from the public service method and dispatches them to the doXXX methods defined in this class. This method is an HTTP-specific version of the
{@link javax.servlet.Servlet#service} method. Theres no
need to override this method.

protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {}

Ref:http://www.docjar.com/html/api/javax/servlet/http/HttpServlet.java.html

  Was this answer useful?  Yes

delindia fathima

  • Dec 22nd, 2011
 

Sorry i was not clear with my previous answer.So posting answer again

We have two service methods in httpServlet
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {}
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {}

First service method,Dispatches client requests to the protected service method.

Second service method,Receives standard HTTP requests from the public service method and dispatches them to the doXXX methods defined in this class. This method is an HTTP-specific version of the
{@link javax.servlet.Servlet#service} method.
Ref:http://www.docjar.com/html/api/javax/servlet/http/HttpServlet.java.html

  Was this answer useful?  Yes

SUJATA WAGHMARE

  • Jan 10th, 2014
 

i think..protected void services(httpservletrequest request,httpservletresponse response)throw ioexcpetion , servletexception...this is modifier for httpservlet class service method...

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions