33. Explain request implicit object

  1. The request object retrieves the values that the client browser passed to the server during an HTTP request such as headers, cookies or parameters associated with the request.
  2. Among the most common use of the request object is to obtain parammeter or query string values.

Servlet Class


The following table summarises the most useful methods available to the request object.

Method Description
getParameter(String name) Returns the value of a request parameter as a String, or null if the parameter does not exist.
getParameterNames() Returns an Enumeration of String objects containing the names of the parameters contained in this request.
getParameterValues(String name) Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist.
getCookies() Gets the array of cookies found in this request. See below for more details on working with cookies.
getQueryString() Gets any query string that is part of the HTTP request URI.
getRequestURI() Gets the URI to the current JSP page.
getHeaderNames() Returns an enumerator of all HTTP header names.
getHeader(String hdr) Returns the value of an HTTP header such as “QUERY_STRING” or “URL”. The method getHeaderNames() can be used to determine what headers are available. See example below.
getAttribute(String) Retrives the object associated with the named attribute.
getAttributeNames() Retrives the names of all attributes currently associated with the session.
setAttribute(String, object) Sets the object to the named attribute. attribute created if it doesn’t exist.
removeAttribute(String) Removes the object bound with the specified name from this session.

One Response

  1. […]  Add comment September 7th, 2006 […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: