Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.servlet
Interface ServletRequest

All Known Subinterfaces:
  CauchoRequest, HttpServletRequest

public interface ServletRequest

ServletRequest encapsulates client request data. See HttpServletRequest for HTTP-specific information.

Requests have user-defined attributes. Servlets can communicate to included or forwarded pages using the request attributes. For example, a servlet may calculate results and place them in the request attributes. It may then forward the call to a JSP template to format the result.

Form parameters are retrieved using `getParameter`

Method Summary
`java.lang.Object` | `getAttribute(java.lang.String name)` Returns an attribute value.
`java.util.Enumeration` | `getAttributeNames()` Enumerates all attribute names in the request.
`java.lang.String` | `getCharacterEncoding()` Returns the character encoding of the POSTed data.
`int` | `getContentLength()` Returns the content length of the data.
`java.lang.String` | `getContentType()` Returns the request's mime-type.
`ServletInputStream` | `getInputStream()` Returns an InputStream to retrieve POST data from the request.
`java.util.Locale` | `getLocale()` Returns the request's preferred locale.
`java.util.Enumeration` | `getLocales()` Returns an enumeration of all locales acceptable by the client.
`java.lang.String` | `getParameter(java.lang.String name)` Returns a form parameter.
`java.util.Enumeration` | `getParameterNames()` Returns an enumeration of all form parameter names.
`java.lang.String[]` | `getParameterValues(java.lang.String name)` Returns all values of a form parameter.
`java.lang.String` | `getProtocol()` Returns the prococol, e.g.
`java.io.BufferedReader` | `getReader()` Returns a reader to read POSTed data.
`java.lang.String` | `getRealPath(java.lang.String uri)` Deprecated.
`java.lang.String` | `getRemoteAddr()` Returns the IP address of the remote host, i.e.
`java.lang.String` | `getRemoteHost()` Returns the DNS hostname of the remote host, i.e.
`RequestDispatcher` | `getRequestDispatcher(java.lang.String uri)` Returns a request dispatcher for later inclusion or forwarding.
`java.lang.String` | `getScheme()` Returns the request scheme, e.g.
`java.lang.String` | `getServerName()` Returns the server name handling the request.
`int` | `getServerPort()` Returns the server port handling the request, e.g.
`boolean` | `isSecure()` Returns true if the connection is secure, e.g.
`void` | `removeAttribute(java.lang.String uri)` Removes the given attribute.
`void` | `setAttribute(java.lang.String name, java.lang.Object o)` Sets an attribute value.

Method Detail

### getProtocol

    public java.lang.String getProtocol()

  Returns the prococol, e.g. "HTTP/1.1"

### getScheme

    public java.lang.String getScheme()

  Returns the request scheme, e.g. "http"

### getServerName

    public java.lang.String getServerName()

  Returns the server name handling the request. When using virtual hosts, this returns the virtual host name, e.g. "vhost1.caucho.com".

### getServerPort

    public int getServerPort()

  Returns the server port handling the request, e.g. 80.

### getRemoteAddr

    public java.lang.String getRemoteAddr()

  Returns the IP address of the remote host, i.e. the client browser.

### getRemoteHost

    public java.lang.String getRemoteHost()

  Returns the DNS hostname of the remote host, i.e. the client browser.

### getParameter

    public java.lang.String getParameter(java.lang.String name)

  Returns a form parameter. When the form contains several parameters of the same name, `getParameter` returns the first.

  For example, calling `getParameter("a")` with the the query string `a=1&a=2` will return "1".

  Parameters:
    `name` - the form parameter to return
  Returns:
    the form value or null if none matches.

### getParameterValues

    public java.lang.String[] getParameterValues(java.lang.String name)

  Returns all values of a form parameter.

  For example, calling `getParameterValues("a")` with the the query string `a=1&a=2` will return ["1", "2"].

  Parameters:
    `name` - the form parameter to return
  Returns:
    an array of matching form values or null if none matches.

### getParameterNames

    public java.util.Enumeration getParameterNames()

  Returns an enumeration of all form parameter names. `

       Enumeration e = request.getParameterNames();
       while (e.hasMoreElements()) {
         String name = (String) e.nextElement();
         out.println(name + ": " + request.getParameter(name));
       }

  `

### getInputStream

    public ServletInputStream getInputStream()
                                      throws java.io.IOException

  Returns an InputStream to retrieve POST data from the request. The stream will automatically end when the end of the POST data is complete.

### getReader

    public java.io.BufferedReader getReader()
                                     throws java.io.IOException,
                                            java.lang.IllegalStateException

  Returns a reader to read POSTed data. Character encoding is based on the request data and is the same as `getCharacterEncoding()`

### getCharacterEncoding

    public java.lang.String getCharacterEncoding()

  Returns the character encoding of the POSTed data.

### getContentLength

    public int getContentLength()

  Returns the content length of the data. This value may differ from the actual length of the data. For newer browsers, i.e. those supporting HTTP/1.1, can support "chunked" encoding which does not make the content length available.

  The upshot is, rely on the input stream to end when the data completes.

### getContentType

    public java.lang.String getContentType()

  Returns the request's mime-type.

### getLocale

    public java.util.Locale getLocale()

  Returns the request's preferred locale.

### getLocales

    public java.util.Enumeration getLocales()

  Returns an enumeration of all locales acceptable by the client.

### isSecure

    public boolean isSecure()

  Returns true if the connection is secure, e.g. it uses SSL.

### getAttribute

    public java.lang.Object getAttribute(java.lang.String name)

  Returns an attribute value.
  Parameters:
    `name` - the attribute name
  Returns:
    the attribute value

### setAttribute

    public void setAttribute(java.lang.String name,
                             java.lang.Object o)

  Sets an attribute value.
  Parameters:
    `name` - the attribute name
    `o` - the attribute value

### getAttributeNames

    public java.util.Enumeration getAttributeNames()

  Enumerates all attribute names in the request.

### removeAttribute

    public void removeAttribute(java.lang.String uri)

  Removes the given attribute.
  Parameters:
    `name` - the attribute name

### getRequestDispatcher

    public RequestDispatcher getRequestDispatcher(java.lang.String uri)

  Returns a request dispatcher for later inclusion or forwarding. This is the servlet API equivalent to SSI includes. `uri` is relative to the request URI. Absolute URIs are relative to the application prefix (`getContextPath()`).

  If `getRequestURI()` is /myapp/dir/test.jsp and the `uri` is "inc.jsp", the resulting page is /myapp/dir/inc.jsp. ``

         RequestDispatcher disp;
         disp = getRequestDispatcher("inc.jsp?a=b");
         disp.include(request, response);

  Parameters:
    `uri` - path relative to `getRequestURI()` (including query string) for the included file.
  Returns:
    RequestDispatcher for later inclusion or forwarding.

### getRealPath

    public java.lang.String getRealPath(java.lang.String uri)

  Deprecated.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD