AB Infinity feb 2014 | Page 4
© Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
5.1
Servlet Equivalent of CGI Variables
HTTP_XXX_YYY
Variables of the form HTTP_HEADER_NAME were how CGI programs
obtained access to arbitrary HTTP request headers. The Cookie header
became HTTP_COOKIE, User-Agent became HTTP_USER_AGENT, Referer became HTTP_REFERER, and so forth. Servlets should just use
request.getHeader or one of the shortcut methods described in
Chapter 4 (Handling the Client Request: HTTP Request Headers).
PATH_INFO
This variable supplies any path information attached to the URL after the
address of the servlet but before the query data. For example, with
http://host/servlet/coreservlets.SomeServlet/foo/bar?baz=quux, the path information is /foo/bar. Since serv-
lets, unlike standard CGI programs, can talk directly to the server, they
don’t need to treat path information specially. Path information could be
sent as part of the regular form data and then translated by getServletContext().getRealPath. Access the value of PATH_INFO by using
re