5.1. Servlet Equivalent of CGI Variables

For each standard CGI variable, this section summarizes its purpose and the means of accessing it from a servlet. As usual, once you are familiar with this information, you may want to use Appendix A (Servlet and JSP Quick Reference) as a reminder. Assume request is the HttpServletRequest supplied to the doGet and doPost methods.

AUTH_TYPE

If an Authorization header was supplied, this variable gives the scheme specified (basic or digest). Access it with request.getAuthType().

CONTENT_LENGTH

For POST requests only, this variable stores the number of bytes of data sent, as given by the Content-Length request header. Technically, since the CONTENT_LENGTH CGI variable is a string, the servlet equivalent is

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.