javax.servlet.http.HttpServletRequest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javaee-16 Show documentation
Show all versions of javaee-16 Show documentation
JavaEE 1.6 API for Resin Java Application Server
/*
* Copyright (c) 1998-2018 Caucho Technology -- all rights reserved
*
* This file is part of Resin(R) Open Source
*
* Each copy or derived work must preserve the copyright notice and this
* notice unmodified.
*
* Resin Open Source is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Resin Open Source is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
* of NON-INFRINGEMENT. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with Resin Open Source; if not, write to the
*
* Free Software Foundation, Inc.
* 59 Temple Place, Suite 330
* Boston, MA 02111-1307 USA
*
* @author Scott Ferguson
*/
package javax.servlet.http;
import javax.servlet.ServletRequest;
import javax.servlet.ServletException;
import java.security.Principal;
import java.util.Collection;
import java.util.Enumeration;
import java.io.IOException;
/**
* HttpServletRequest encapsulates client request data.
*
* URI
*
* The servlet engine splits the URI into three useful
* sections: the context path (application prefix), the servlet path,
* and the path info.
*
* For example, given an application prefix of '/myapp', the api
* /myapp/dir/test.jsp/data
will be split as follows:
*
*
* /myapp/dir/test.jsp/data getRequestURI()
* /myapp getContextPath()
* /dir/test.jsp getServletPath()
* /data getPathInfo()
*
*
* Useful headers
*
*
* User-Agent String describing the browser's version
*
*
* CGI equivalents
*
*
* AUTH_TYPE getAuthType()
* CONTENT_TYPE getContentType()
* CONTENT_LENGTH getContentLength()
* PATH_INFO getPathInfo()
* PATH_TRANSLATED getPathTranslated()
* QUERY_STRING getQueryString()
* REMOTE_ADDR getRemoteAddr()
* REMOTE_HOST getRemoteHost()
* REMOTE_USER getRemoteUser()
* REQUEST_METHOD getMethod()
* SCRIPT_NAME getServletPath()
* SERVER_NAME getServerName()
* SERVER_PROTOCOL getProtocol()
* SERVER_PORT getServerPort()
*
*
* Form data
*
* For form data, see ServletRequest.getParameter()
*/
public interface HttpServletRequest extends ServletRequest {
/**
* String identifier for basic authentication. Value "BASIC".
*/
public final static String BASIC_AUTH = "BASIC";
/**
* String identifier for client cert authentication. Value "CLIENT_CERT".
*/
public final static String CLIENT_CERT_AUTH = "CLIENT_CERT";
/**
* String identifier for digest authenciation. Value "DIGEST".
*/
public final static String DIGEST_AUTH = "DIGEST";
/**
* String identifier for form authenciation. Value "FORM".
*/
public final static String FORM_AUTH = "FORM";
/**
* Returns the HTTP method, e.g. "GET" or "POST"
*
* Equivalent to CGI's REQUEST_METHOD
*/
public String getMethod();
/**
* Returns the entire request URI
*/
public String getRequestURI();
/**
* Reconstructs the URL the client used for the request.
*
* @since Servlet 2.3
*/
public StringBuffer getRequestURL();
/**
* Returns the part of the URI corresponding to the application's
* prefix. The first part of the URI selects applications
* (ServletContexts).
*
* getContextPath()
is /myapp for the uri
* /myapp/servlet/Hello,
*/
public String getContextPath();
/**
* Returns the URI part corresponding to the selected servlet.
* The URI is relative to the application.
*
* Returns an emtpy string for a servlet matched on /*
*
*
Corresponds to CGI's SCRIPT_NAME
*
* getServletPath()
is /servlet/Hello for the uri
* /myapp/servlet/Hello/foo.
*
* getServletPath()
is /dir/hello.jsp
* for the uri /myapp/dir/hello.jsp/foo,
*/
public String getServletPath();
/**
* Returns the URI part after the selected servlet and null if there
* is no suffix.
*
* Corresponds to CGI's PATH_INFO
*
* getPathInfo()
is /foo for
* the uri /myapp/servlet/Hello/foo.
*
* getPathInfo()
is /hello.jsp for for the uri
* /myapp/dir/hello.jsp/foo.
*/
public String getPathInfo();
/**
* Returns the physical path name for the path info.
*
*
Corresponds to CGI's PATH_TRANSLATED
*
* @return null if there is no path info.
*/
public String getPathTranslated();
/**
* Returns the request's query string. Form based servlets will use
* ServletRequest.getParameter()
to decode the form values.
*
* Corresponds to CGI's PATH_TRANSLATED
*/
public String getQueryString();
/**
* Returns the first value for a request header.
*
* Corresponds to CGI's HTTP_*
*
*
* String userAgent = request.getHeader("User-Agent");
*
*
* @param name the header name
* @return the header value
*/
public String getHeader(String name);
/**
* Returns all the values for a request header. In some rare cases,
* like cookies, browsers may return multiple headers.
*
* @param name the header name
* @return an enumeration of the header values.
*/
public Enumeration getHeaders(String name);
/**
* Returns an enumeration of all headers sent by the client.
*/
public Enumeration getHeaderNames();
/**
* Converts a header value to an integer.
*
* @param name the header name
* @return the header value converted to an integer
*/
public int getIntHeader(String name);
/**
* Converts a date header to milliseconds since the epoch.
*
*
* long mod = request.getDateHeader("If-Modified-Since");
*
*
* @param name the header name
* @return the header value converted to an date
*/
public long getDateHeader(String name);
/**
* Returns an array of all cookies sent by the client.
*/
public Cookie []getCookies();
/**
* Returns a session. If no session exists and create is true, then
* create a new session, otherwise return null.
*
* @param create If true, then create a new session if none exists.
*/
public HttpSession getSession(boolean create);
/**
* Returns the current session, creating one if necessary.
* Sessions are a convenience for keeping user state
* across requests.
*/
public HttpSession getSession();
/**
* Returns the session id. Sessions are a convenience for keeping
* user state across requests.
*
* The session id is the value of the JSESSION cookie.
*/
public String getRequestedSessionId();
/**
* Returns true if the session is valid.
*/
public boolean isRequestedSessionIdValid();
/**
* Returns true if the session came from a cookie.
*/
public boolean isRequestedSessionIdFromCookie();
/**
* Returns true if the session came URL-encoding.
*/
public boolean isRequestedSessionIdFromURL();
/**
* Returns the auth type, i.e. BASIC, CLIENT-CERT, DIGEST, or FORM.
*/
public String getAuthType();
/**
* Returns the remote user if authenticated.
*/
public String getRemoteUser();
/**
* Returns true if the user is in the given role.
*/
public boolean isUserInRole(String role);
/**
* Returns the equivalent principal object for the authenticated user.
*/
public Principal getUserPrincipal();
/**
* @deprecated
*/
public boolean isRequestedSessionIdFromUrl();
/**
* @since Servlet 3.0
*/
public boolean authenticate(HttpServletResponse response)
throws IOException,ServletException;
/**
* @since Servlet 3.0
*/
public void login(String username, String password)
throws ServletException;
/**
* @since Servlet 3.0
*/
public void logout()
throws ServletException;
/**
* @since Servlet 3.0
*/
public Collection getParts()
throws IOException, ServletException;
/**
* @since Servlet 3.0
*/
public Part getPart(String name)
throws IOException, ServletException;
}