HttpServletRequest Interface

public interface HttpServletRequest extends ServletRequest
The HttpServletRequest interface is meant to encapsulate HTTP, this interface (combiation with the methods provided in the ServletRequest interface) provides numerous methods for accessing the HTTP request.
Method of HttpServletRequest Interface
  1. public String getAuthType()
              This method returns the name of the authentication scheme used to protect the servlet, for example, "BASIC" or "SSL," or null if the servlet was not protected.
  2. public String getContextPath()
              This method returns the portion of the request URI that indicates the context of the request.
  3. public Cookie[] getCookies()
              This method returns an array containing all of the Cookie objects the client sent with this request.
  4. public long getDateHeader(String name)
              This method returns the value of the specified request header as a long value that represents a Date object.  
  5. public String getHeader(String name)
              This method returns the value of the specified request header as a String.
  6. public Enumeration getHeaderNames()
              This method returns an enumeration of all the header names this request contains.
  7. public Enumeration getHeaders (String name)
              This method returns all the values of the specified request header as an Enumeration of String objects.
  8. publicĀ int getIntHeader(String name)
              This method returns the value of the specified request header as an int.
  9. public String getMethod()
              This method returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.
  10. public String getPathInfo()
              This method returns any extra path information associated with the URL the client sent when it made this request.
  11. public String getPathTranslated()
              This method returns any extra path information after the servlet name but before the query string, and translates it to a real path.  
  12. public String getQueryString()
              This method returns the query string that is contained in the request URL after the path.  
  13. public String getRemoteUser()
              This method returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated.
  14. public String getRequestedSessionId()
              This method returns the session ID specified by the client.
  15. public String getRequestURI()
              This method returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.
  16. public String getServletPath()
              This method returns the part of this request's URL that calls the servlet.
  17. public HttpSession getSession()
              This method returns the current session associated with this request, or if the request does not have a session, creates one.
  18. public HttpSession getSession(boolean create)
              This method returns the current HttpSession associated with this request or, if if there is no current session and create is true, returns a new session.
  19. public Principal getUserPrincipal()
              This method returns a java.security.Principal object containing the name of the current authenticated user.
  20. public boolean isRequestedSessionIdFromCookie()
              This method checks whether the requested session ID came in as a cookie.
  21. public boolean isRequestedSessionIdFromUrl()
              Deprecated. As of Version 2.1 of the Java Servlet API, use isRequestedSessionIdFromURL() instead.  
  22. public boolean isRequestedSessionIdFromURL()
              This method checks whether the requested session ID came in as part of the request URL.
  23. public boolean isRequestedSessionIdValid()
              This method checks whether the requested session ID is still valid.
  24. public boolean isUserInRole(String role)
              This method returns a boolean indicating whether the authenticated user is included in the specified logical "role".
 



 

Latest Tutorial


Most Visited Tutorial