HttpServletRequest is an interface and extends the ServletRequest interface. By extending the ServletRequest this interface is able to allow request information for HTTP Servlets. Object of the HttpServletRequest is created by the Servlet container and, then, it is passed to the service method (doGet(), doPost(), etc.) of the Servlet.
Extends the ServletRequest interface to provide request information for HTTP servlets.
The servlet container creates an HttpServletRequest object and passes it as an argument to the servlet’s service methods (doGet, doPost, etc.).
i. public String getAuthType()
Returns the name of the authentication scheme used to protect the servlet.
ii. public String getContextPath ()
Returns the portion of the request URI that indicates the context of the request.
iii. public Cookie [] getCookies ( )
Returns an array containing all of the cookie objects the client sent with this request.
iv public long getDateHeader(String name)
Returns the value of the specified request header as a long value that represents a date object.
v public String getHeader(String name)
Returns the value of the specified request header as a string.
vi. public Enumeration getHeaderNames()
Returns an enumeration of all the header names this request contains.
vii. public Enumeration getHeaders (String name)
Returns all the values of the specified request header as an enumeration of String objects.
viii. public int getIntHeader (String name)
Returns the value of the specified request header as an int.
ix. public String getMethod()
Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT, same as the value of the CGI variable REQUEST_METHOD.
x. public String getPathlnfo()
Returns any extra path information associated with the URL the client sent when it made this request.
xi. public String getpathTranslated ()
Returns any extra path information after the servlet name but before the query string, and translates it to a real path.
xii. public String getQueryString ()
Returns the query string that is contained in the request URL after the path.
xiii. public String getRemoteUser ()
Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated.
xiv public String getRequestedSessionld()
Returns the session ID specified by the client.
xv public String getRequestURI()
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.
xvi. public StringBuffer getRequestURL()
Reconstructs the URL the client used to make the request.
xvii.public String getServletpath ()
Returns the part of this request’s URL that calls the serv let.
xviii.public HttpSession getSession ()
Returns the current session associated with this request, or if the request does not have a session, creates one.
xix. public HttpSession getSession(boolean create)
Returns the current HttpSession associated with this request or, if there is no current session and create is true, returns a new session.
xx. public Principal getUserPrincipal()
Returns a java.security. Principal object containing the name of the current authenticated user.
xxi. public boolean isRequestedSessionldFromCookie()
Checks whether the requested session ID came in as a cookie.
xxii. public boolean isRequestedSessionldValid()
Checks whether the requested session ID is still valid.
xxiii. public boolean isUserlnRole (String role)
Returns a boolean indicating whether the authenticated user is included in the specified logical role.