In this tutorial you will learn about the service method in servlet that how can it be defined, how to get information from requests , and how the response can be constructed.
In this tutorial you will learn about the service method in servlet that how can it be defined, how to get information from requests , and how the response can be constructed.In this tutorial you will learn about the service method in servlet that how can it be defined, how to get information from requests , and how the response can be constructed.
service method is a method of servlet class which is to be written for providing service to a client. It does write in GenericServlet's service doXXXX() method (in doXXXX() method there can be get, post, delete, put etc in place of XXXX) of an HttpServlet object or could be the any type of protocol-specific methods specified in a class which is implemented by the Servlet interface. Generally, information is extracted from the request object, getting the external resources according to the information and then a response is populated. But in HTTP servlets the following procedure has to be followed to populate the response correctly :
Adding/setting headers after when a response is committed the web container will ignore this attempt. So, it should be noted that the Request header must be set before the commitment of response.
Request is a data that is passed from the client to a servlet. To get the information from request methods of an interface ServletRequest that is implemented by the every request can get the following information :
Except these information you can also read an input stream and parse the data manually.
Response is a data that is passed from the server to the client. ServletResponse interface is implemented by the every response. Using this interface that defines method which will permits you for the following :
Ads