JSP CGI - A JSP that prints the equivalent of CGI variables

I created a JSP this morning that prints out the equivalent of most traditional CGI parameters. Sometimes I use these to debug a problem, other times I use them within JSP/servlet code for other non-debug purposes.

Here's the Java source code for my JSP CGI page, which I named cgiParams.jsp. As you can see, most of these variables come from the JSP request object:

JSP-equivalents to CGI variables:

AUTH_TYPE:       <%= request.getAuthType() %>
CONTENT_LENGTH:  <%= request.getContentLength() %>
CONTENT_TYPE:    <%= request.getContentType() %>
PATH_INFO:       <%= request.getPathInfo() %>
PATH_TRANSLATED: <%= request.getPathTranslated() %>
QUERY_STRING:    <%= request.getQueryString() %>
REMOTE_ADDR:     <%= request.getRemoteAddr() %>
REMOTE_HOST:     <%= request.getRemoteHost() %>
REMOTE_USER:     <%= request.getRemoteUser() %>
REQUEST_METHOD:  <%= request.getMethod() %>
SCRIPT_NAME:     <%= request.getServletPath() %>
SERVER_NAME:     <%= request.getServerName() %>
SERVER_PORT:     <%= request.getServerPort() %>
SERVER_PROTOCOL: <%= request.getProtocol() %>
SERVER_SOFTWARE: <%= getServletContext().getServerInfo() %>

Other parameters I'm often interested in:

Request URI:          <%= request.getRequestURI() %>
Request URL:          <%= request.getRequestURL() %>
Request Context Path: <%= request.getContextPath() %>
Real Path:            <%= getServletContext().getRealPath("/") %>

And here's the actual output I get when I hit this JSP from my browser. I recorded this output with the JSP running on my Mac laptop under Tomcat:

JSP-equivalents to CGI variables:

AUTH_TYPE:       null
CONTENT_LENGTH:  -1
CONTENT_TYPE:    null
PATH_INFO:       null
PATH_TRANSLATED: null
QUERY_STRING:    null
REMOTE_ADDR:     127.0.0.1
REMOTE_HOST:     localhost
REMOTE_USER:     null
REQUEST_METHOD:  GET
SCRIPT_NAME:     /cgiParams.jsp
SERVER_NAME:     localhost
SERVER_PORT:     8080
SERVER_PROTOCOL: HTTP/1.1
SERVER_SOFTWARE: Apache Tomcat/4.1.31

Other parameters I'm often interested in:

Request URI:          /blog/cgiParams.jsp
Request URL:          http://localhost:8080/blog/cgiParams.jsp
Request Context Path: /blog
Real Path:            /Users/alvin/tomcat-4.1.31/webapps/blog/

Here are a few good places where you can find more information on this topic: