What are the parameters of the service method ?

Answers were Sorted based on User's Feedback



What are the parameters of the service method ?..

Answer / chadnra kunchala

well, there are two service methods we have.
one is, public service()
second is protected service()

when ever a browser sends a request to server, first it
invokes public service(ServeletRequest req, ServletResponse
res) throws ServletException, IOException
{ }
after calling public service method it invokes the protected
service() method like the following
public service(ServletRequest req, ServletResponse res)
throws ServletException, IOException
{
HttpServletRequest hreq = (HttpServletRequest)req;
HttpServletResponse hres = (HttpServletresponse)res;
protected service(hreq, hres);
}
then,
The protected service() method will idendtify the
requested method whether it is GET OR POST OR PUT like that
, then it invokes the correspondin method like doGet()or
doPost() or doPut() like that..

recommended to override doGet() or doPost() or and..... so
on, not service method()..

Is This Answer Correct ?    10 Yes 5 No

What are the parameters of the service method ?..

Answer / shakir khan

service() method called servlet to handle client request in
a new thread.service() method accepts ServletRequest and
ServletResponse objects as parameters.ServletRequest object
contains client requests.It contains data sent in
name/value pairs.

ServletResponse object is used to send the respose to the
client.

public void service(ServletRequest req,ServletResponse res)
throws ServletException,IOException
{
}

Is This Answer Correct ?    10 Yes 10 No

Post New Answer

More Servlets Interview Questions

When is the servlet instance created in the life cycle of servlet? What is the importance of configuring a servlet?

0 Answers  


What is servlet container?

0 Answers  


What are the important functions of filters?

0 Answers  


Why is it that we can't give relative URL's when using ServletContext.getRequestDispatcher() when we can use the same while calling ServletRequest.getRequestDispatcher()?

0 Answers  


Once the destroy() method is called by the container, will the servlet be immediately destroyed? What happens to the tasks(threads) that the servlet might be executing at that time?

0 Answers  






give the syntax of doGet() and doPost()?

2 Answers  


i have class files in class folder. but i have no java files. but i want to modify the java files which are related to class files . how ?

5 Answers   TCS,


Is it good idea to create servlet constructor?

0 Answers  


Difference between GET and POST?

0 Answers  


How can we upload the file to the server using servlet?

0 Answers  


Can you send an authentication error from a servlet?

0 Answers  


how this statement works..? public void service(HttpServletRequest request,HttpServletResponse response)

2 Answers   TCS,


Categories