Java ServletRequest Interface
Overview
Java ServletRequest Interface defines an object that provides client request information to the servlet. The servlet container creates a ServletRequest object and passes it to the servlet’s service() method as an argument.
ServletRequest Interface
The ServletRequest interface is defined in the javax.servlet package.
public interface ServletRequest {
…
}
The service() method is invoked by the servlet container to allow the servlet to process the request and respond with a response. The signature of the service() method is as follows:
service​(ServletRequest req, ServletResponse res)
The req and res are the references to the ServletRequest and ServletResponse interfaces.
When a client request is issued the container creates objects of ServletRequest and ServletResponse interfaces. The container will pass those objects to the service() method. We use interface names in the service() method to make the servlet server independent. If we directly write the class names in the service() method then the servlet becomes server dependent.
—
Java Tutorials
Java Tutorial on this website:
https://www.testingdocs.com/java-tutorial/
For more information on Java, visit the official website :