A.5. Accessing the Standard CGI Variables
You should usually think in terms of request info, response info, and server info, not CGI variables.
Capabilities Not Discussed Elsewhere
getServletContext().getRealPath("uri"): maps URI to real path
request.getRemoteHost(): name of host making request
request.getRemoteAddress(): IP address of host making request
Servlet Equivalent of CGI Variables
AUTH_TYPE: request.getAuthType()
CONTENT_LENGTH: request.getContentLength()
CONTENT_TYPE: request.getContentType()
DOCUMENT_ROOT: getServletContext().getRealPath("/")
HTTP_XXX_YYY: request.getHeader("Xxx-Yyy")
PATH_INFO: request.getPathInfo()
PATH_TRANSLATED: request.getPathTranslated()
QUERY_STRING: request.getQueryString()
REMOTE_ADDR: request.getRemoteAddr()
REMOTE_HOST: ...
Get Core Servlets and JavaServer Pages™ 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.