servletrequest interface

What is ServletRequest interface

The servlet container creates a ServletRequest object and passes it as an argument to the servlet’s service method.

By the help of ServletRequest object we can get data parameter name and values, attributes, and an input stream.

When to use ServletRequest

When we want to get the values of HTML control which all are written in JSP page then we have to create object of ServletRequest or HttpServletRequest.

Methods of ServletRequest

Method Name: Description
public String getParameter(String name) returns value of parameter by name
public String[] getParameterValues(String name) returns an array objects that contains all the values of the request parameter.
Enumeration getParameterNames() return the all parameter names.
public ServletInputStream getInputStream() returns data in streams format
public int getContentLength() returns the size of the request data.
public String getContentType() returns the content type of request data.
public String getServerName() returns the server name.
public int getServerPort() returns the port number from which request received

Full-stack web and mobile app development company Contact Us : Skype: indore.webcoder Email: Sales: +91 8085506229