Saturday, 23 April 2016

What are the main methods of HttpServletRequest interface ?


Interface javax.servlet.http.HttpServletRequest 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..).

HttpServletRequest methods
HttpSession getSession()
Returns the current session associated with this request, or if the request does not have a session, creates one.

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.

Cookie[] getCookies()
Returns an array containing all of the Cookie objects the client sent with this request.

String getRequestedSessionId()
Returns the session ID specified by the client.

boolean isRequestedSessionIdFromCookie()
Checks whether the requested session ID came in as a cookie.

boolean isRequestedSessionIdFromURL()
Checks whether the requested session ID came in as part of the request URL.

boolean isRequestedSessionIdValid()
Checks whether the requested session ID is still valid.

RequestDispatcher getRequestDispatcher(String path)
Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path.

String getMethod()
Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.

String getAuthType()
Returns the name of the authentication scheme used to protect the servlet.

String getQueryString()
Returns the query string that is contained in the request URL after the path.

String getContextPath()
Returns the portion of the request URI that indicates the context of the request.

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.

StringBuffer getRequestURL()
Reconstructs the URL the client used to make the request.

String getServletPath()
Returns the part of this request's URL that calls the servlet.

String getPathInfo()
Returns any extra path information associated with the URL the client sent when it made this request.

String getPathTranslated()
Returns any extra path information after the servlet name but before the query string, and translates it to a real path.

String getHeader(String name)
Returns the value of the specified request header as a String.

long getDateHeader(String name)
Returns the value of the specified request header as a long value that represents a Date object.

int getIntHeader(String name)
Returns the value of the specified request header as an int.

Enumeration getHeaders(String name)
Returns all the values of the specified request header as an Enumeration of String objects.

Enumeration getHeaderNames()

Returns an enumeration of all the header names this request contains.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.