The service method
public void service (ServletRequest req, ServletResponse res)
Each request message from the client results in invoking the service method.
There are two ways the client can send information:
- parameter name/value pairs
- streams - the servlet can invoke getInputStream(), which returns a ServletInputStream.
Similarly, the servlet can invoke getOutputStream () to generate the response. Other methods, such as setContentType can set information that the web server will use in generating the output to the client.
More than one instance of the service method can be invoked at one time to respond to multiple requests.