Name

ServletRequest

Synopsis

A ServletRequest object encapsulates information about a client request. The server passes a ServletRequest object to the service() method of a servlet. ServletRequest provides access to request parameters, such as form values or other request-specific parameters. These are accessed using the getParameterNames(), getParameter(), and getParameterValues() methods. Raw request data can be read by the getReader() method (for textual data) and the getInputStream() method (for binary data). The getContentType(), getContentLength(), and getCharacterEncoding() methods can help retrieve this information. Other methods provide information about the client (getRemoteAddr(), getRemoteHost()), the request itself (getScheme(), getProtocol()), and the server (getServerName(), getServerPort()). Version 2.1 also adds the getAttribute() and setAttribute() methods, which are generally used in conjunction with the new RequestDispatcher interface.

public interface ServletRequest {
// Property Accessor Methods (by property name)
   public abstract java.util.Enumeration getAttributeNames();    // 2.1
   public abstract String getCharacterEncoding();  
   public abstract void setCharacterEncoding(                    // 2.3
        String env) throws UnsupportedEncodingException;  
   public abstract int getContentLength();  
   public abstract String getContentType();  
   public abstract ServletInputStream getInputStream(
        ) throws IOException;  
   public abstract java.util.Locale getLocale();                 // 2.2 public abstract java.util.Enumeration ...

Get Java Enterprise in a Nutshell, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.