ServletRequest Interface

public interface ServletRequest
This interface specifies an abstraction of client requests for Servlet. The web container creates an instance of this object while calling the service() method of the GenericServlet or the HttpServlet.
Method of ServletRequest Interface
  1. public Object getAttribute(String name)
             This method returns the value of the named attribute as an Object, or null if no attribute of the given name exists.  
  2. public Enumeration getAttributeNames()
              This method returns an Enumeration containing the names of the attributes available to this request.
  3. public String getCharacterEncoding()
              This method returns the name of the character encoding used in the body of this request.  
  4. public int getContentLength()
              This method returns the length, in bytes, of the request body and made available by the input stream, or -1 if the length is not known.  
  5. public String getContentType()
              This method returns the MIME type of the body of the request, or null if the type is not known.
  6. public ServletInputStream getInputStream()
             This method retrieves the body of the request as binary data using a ServletInputStream.
  7. public String getLocalAddr()
              This method returns the Internet Protocol (IP) address of the interface on which the request was received.
  8.  public Locale getLocale()
              This method returns the preferred Locale that the client will accept content in, based on the Accept-Language header.
  9. public Enumeration getLocales()
              This method returns an Enumeration of Locale objects indicating, in decreasing order starting with the preferred locale, the locales that are acceptable to the client based on the Accept-Language header.
  10.   public String getLocalName()
             This method returns the host name of the Internet Protocol (IP) interface on which the request was received.
  11. public int getLocalPort()
             This method returns the Internet Protocol (IP) port number of the interface on which the request was received.
  12.  public String getParameter(String name)
              This method returns the value of a request parameter as a String, or null if the parameter does not exist.
  13.   public Map getParameterMap()
              This method returns a Map of the parameters of this request.  
  14. public Enumeration getParameterNames()
              This method returns an Enumeration of String objects containing the names of the parameters contained in this request.
  15.  public String[] getParameterValues(String name)
              This method returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist.
  16.   public String getProtocol()
              This method returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1.
  17.  public BufferedReader getReader()
              This method retrieves the body of the request as character data using a BufferedReader.
  18. public String getRealPath(String path)
              Deprecated. As of Version 2.1 of the Java Servlet API, use ServletContext.getRealPath(java.lang.String) instead.
  19.  public String getRemoteAddr()
             This method returns the Internet Protocol (IP) address of the client or last proxy that sent the request.
  20. public String getRemoteHost()
              This method returns the fully qualified name of the client or the last proxy that sent the request.
  21.  public int getRemotePort()
              This method returns the Internet Protocol (IP) source port of the client or last proxy that sent the request.
  22.  public RequestDispatcher getRequestDispatcher (String path)
              This method returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path.
  23.  public String getScheme()
              This method returns the name of the scheme used to make this request, for example, http, https, or ftp.
  24. public String getServerName()
             This method returns the host name of the server to which the request was sent.
  25.  public int getServerPort()
              This method returns the port number to which the request was sent.
  26.  public boolean isSecure()
              This method returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
  27.   public void removeAttribute(String name)
             This method removes an attribute from this request.
  28.  public void setAttribute(String name, Object o)
              This method stores an attribute in this request.
  29.   public void setCharacterEncoding(String env)
             This method overrides the name of the character encoding used in the body of this request.
 



 

Latest Tutorial


Most Visited Tutorial