ServletRequest vs ServletResponse
ServletRequest and ServletResponse are two interfaces that serve as the backbone of servlet technology implementation. They belong to the javax.servlet package.
- Signature: public interface ServletRequest
Blueprint of an object to provide client request information to a servlet. The servlet container creates a ServletRequest object and sends it as an argument to the servlet’s service method.
- Signature: public interface ServletResponse
Blueprint of an object to assist a servlet in sending a response to the client. The servlet container creates a ServletResponse object and passes it as an argument to the servlet’s service method. Data that needs to be sent to the client will be put inside the ServletResponse object. To send binary data back to the client in a MIME body response, use the ServletOutputStream from the ServletResponse object by calling the getOutputStream() method. To send character data to the client, the PrintWriter object returned by getWriter() should be used.
This Servlet tutorial was added on 06/05/2008.