Reference
JSP and Servlet Reference

Request Object

Servlet class: javax.servlet.HttpServletRequest API. Contains data included with the HTTP Request. The following are the more common methods.

To obtain all cookies included with the request,

javax.servlet.http.Cookie[] cookies = request.getCookies();

To obtain the value of a specific request header,

String headerVal = request.getHeader("header");

To obtain the preferred Locale of the request,

java.util.Locale loc = request.getLocale();

To obtain the value of a request parameter,

String val = request.getParameter("paramName");

To obtain an array of all parameter names,

java.util.Enumeration e = request.getParameterNames();

To return all values sent for the same parameter,

String[] vals = request.getParameterValues();

To get the session object for the request,

javax.servlet.http.HttpSession session = request.getSession();

Response Object

Servlet class: javax.servlet.HttpServletResponse API. Provides access to the response. The following are the more common methods.

To create a cookie,

Cookie c = new Cookie("Name", "Value");
response.addCookie(c);

To set the content type of the response,

response.setContentType("content type");

Encodes the specified URL by including the session ID,

response.encodeURL("url");

To forces any content in the buffer to be written to the client,

response.flushBuffer();

To set the value of a response header,

response.setHeader("header", "value");

Sends a temporary redirect response to the client using the specified redirect location URL,

response.sendRedirect("location");

Session Object

Servlet class: javax.servlet.HttpSession API. The session object represents an end user's session.

To obtain an object held as a session attribute,

Object o = session.getAttribute("attribute");

To set an object to be held as a session attribute,

session.setAttribute("name", object);

To remove an object that is held as a session attribute,

session.removeAttribute("attribute");

Application Object

Servlet class: javax.servlet.ServletContext API. The application object represents the web application.

To obtain an object held as an application attribute,

Object o = application.getAttribute("attribute");

To set an object to be held as an application attribute,

application.setAttribute("name", object);

To remove an object that is held as an application attribute,

application.removeAttribute("attribute");

To obtain the value of a web application initialisation parameter,

String val = application.getInitParameter("param");