request  
 
Variable name:

request

 
Interface name:

javax.servlet.http.HttpServletRequest

 
Extends:

javax.servlet.ServletRequest

 
Implemented by:

Internal container-dependent class

 
JSP page type:

Available in both regular JSP pages and error pages

 
Description

The request variable is assigned a reference to an internal container-dependent class that implements a protocol-dependent interface that extends the javax.servlet.ServletRequest interface. Since HTTP is the only protocol supported by JSP 1.1, the class always implements the javax.servlet.http.HttpServletRequest interface. The method descriptions in this section include the methods from both interfaces.

getAttribute()  
public Object getAttribute(String name)

Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.

getAttributeNames()  
public java.util.Enumeration getAttributeNames()

Returns an Enumeration containing the names of the attributes available to this request. The Enumeration is empty if the request doesn't have any attributes.

getAuthType()  
public String getAuthType()

Returns the name of the authentication scheme used to protect the servlet (for example, BASIC or SSL), or null if the servlet is not protected.

getCharacterEncoding()  
public String getCharacterEncoding()

Returns the name of the character encoding method used in the body of this request, or null if the request does not specify a character encoding method.

getContentLength()  
public int getContentLength()

Returns the length, in bytes, of the request body (if it is made available by the input stream), or -1 if the length is not known.

getContentType()  
public String getContentType()

Returns the MIME type of the body of the request, or null if the type is not known.

getContextPath()  
public String getContextPath()

Returns the portion of the request URI that indicates the context of the request.

getCookies()  
public Cookie[] getCookies()

Returns an array containing all the Cookie objects the client sent with this request, or null if the request contains no cookies.

getDateHeader()  
public long getDateHeader(String name)

Returns the value of the specified request header as a long value that represents a date value, or -1 if the header is not included in the request.

getHeader()  
public String getHeader(String name)

Returns the value of the specified request header as a String, or null if the header is not included with the request.

getHeaderNames()  
public java.util.Enumeration getHeaderNames()

Returns all the header names this request contains as an Enumeration of String objects. The Enumeration is empty if the request doesn't have any headers.

getHeaders()  
public java.util.Enumeration getHeaders(String name)

Returns all the values of the specified request header as an Enumeration of String objects. The Enumeration is empty if the request doesn't contain the specified header.

getInputStream()  
public ServletInputStream getInputStream()
  throws java.io.IOException

Retrieves the body of the request as binary data using a ServletInputStream.

getIntHeader()  
public int getIntHeader(String name)

Returns the value of the specified request header as an int, or -1 if the header is not included in the request.

getLocale()  
public java.util.Locale getLocale()

Returns the preferred Locale in which the client will accept content, based on the Accept-Language header.

getLocales()  
public java.util.Enumeration getLocales()

Returns an Enumeration of Locale objects indicating, in decreasing order and starting with the preferred locale, the locales that are acceptable to the client based on the Accept-Language header.

getMethod()  
public String getMethod()

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

getParameter()  
public String getParameter(String name)

Returns the value of a request parameter as a String, or null if the parameter does not exist.

getParameterNames()  
public String getParameterNames()

Returns an Enumeration of String objects containing the names of the parameters in this request.

getParameterValues()  
public String[] getParameterValues()

Returns an array of String objects containing all of the given request parameter's values, or null if the parameter does not exist.

getPathInfo()  
public String getPathInfo()

Returns any extra path information associated with the URI the client sent when it made this request, or null if there is no extra path information. For a JSP page, this method always returns null.

getPathTranslated()  
public String getPathTranslated()

Returns the result of getPathInfo() translated into the corresponding filesystem path. Returns null if getPathInfo() returns null.

getProtocol()  
public String getProtocol()

Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion; for example, HTTP/1.1.

getQueryString()  
public String getQueryString()

Returns the query string that is contained in the request URI after the path.

getReader()  
public java.io.BufferedReader getReader() throws java.io.IOException

Retrieves the body of the request as character data using a BufferedReader.

getRemoteAddr()  
public String getRemoteAddr()

Returns the Internet Protocol (IP) address of the client that sent the request.

getRemoteHost()  
public String getRemoteHost()

Returns the fully qualified name of the client host that sent the request or, if the hostname cannot be determined, the IP address of the client.

getRemoteUser()  
public String getRemoteUser()

Returns the login ID of the user making this request if the user has been authenticated, or null if the user has not been authenticated.

getRequestDispatcher()  
public RequestDispatcher getRequestDispatcher(String path)

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

getRequestedSessionId()  
public String getRequestedSessionId()

Returns the session ID specified by the client.

getRequestURI()  
public String getRequestURI()

Returns the part of this request's URI from the protocol name up to the query string in the first line of the HTTP request.

getScheme()  
public String getScheme()

Returns the name of the scheme (protocol) used to make this request; for example, http, https, or ftp.

getServerName()  
public String getServerName()

Returns the hostname of the server that received the request.

getServerPort()  
public int getServerPort()

Returns the port number on which the request was received.

getServletPath()  
public String getServletPath()

Returns the part of this request's URI that calls the servlet. For a JSP page, this is the page's complete context-relative path.

getSession()  
public HttpSession getSession()

Returns the current HttpSession associated with this request. If the request does not have a session, a new HttpSession object is created, associated with the request, and returned.

getSession()  
public HttpSession getSession(boolean create)

Returns the current HttpSession associated with this request. If there is no current session and create is true, a new HttpSession object is created, associated with the request, and returned. If create is false and the request is not associated with a session, this method returns null.

getUserPrincipal()  
public java.security.Principal getUserPrincipal()

Returns a Principal object containing the name of the current authenticated user.

isRequestedSessionIdFromCookie()  
public boolean isRequestedSessionIdFromCookie()

Checks if the requested session ID came in as a cookie.

isRequestedSessionIdFromURL()  
public boolean isRequestedSessionIdFromURL()

Checks if the requested session ID came in as part of the request URL.

isRequestedSessionIdValid()  
public boolean isRequestedSessionIdValid()

Checks if the requested session ID is still valid.

isSecure()  
public boolean isSecure()

Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS, or not.

isUserInRole()  
public boolean isUserInRole(String role)

Returns a boolean indicating whether the authenticated user is included in the specified logical role or not.

removeAttribute()  
public void removeAttribute(String name)

Removes the specified attribute from the request.

setAttribute()  
public Object setAttribute(String name, Object attribute)

Stores the specified attribute in the request.

getRealPath() Deprecated
public String getRealPath()

As of the Servlet 2.1 API, use ServletContext.getRealPath(String) instead.

isRequestSessionIdFromUrl() Deprecated
public boolean isRequestSessionIdFromUrl()

As of the Servlet 2.1 API, use isRequestedSessionIdFromURL() instead.