Sun Java System Web Server 7.0 Developer's Guide to Java Web Applications

Accessing Parameters and Storing Data

Incoming data is encapsulated in a request object. For HTTP servlets, the request object type is HttpServletRequest. For generic servlets, the request object type is ServletRequest. The request object contains all request parameters, including custom values called attributes.

To access all incoming request parameters, use the getParameter() method, for example:

String username = request.getParameter("username");

Set and retrieve values in a request object using setAttribute() and getAttribute(), respectively, for example:

request.setAttribute("favoriteDwarf", "Dwalin");