[ Team LiB ] Previous Section Next Section


In one of the longer hours of the book, you've just learned about most of the objects and methods needed to work effectively with servlets. Because JavaServer Pages ultimately become servlets, you also know how to work with objects that are important to JSPs. You studied the details of the perennial request and response objects, ServletRequest, HttpServletRequest, ServletResponse, and HttpServletResponse. You saw how to use the ServletInputStream and ServletOutputStream classes to read from and write to buffers that contain client data, and how to manage those buffers.

An important application-level class is ServletContext. It provides access to information about the servlet container, initialization parameters, system-wide logging, and application resources such as images. In addition, you can forward or redirect pages using a RequestDispatcher.

Sessions are used to group related requests and are often tracked by using cookies. HttpSession is a class used to create and manage sessions.

Storing attributes that can be associated with a request, context, or session is important. Each of the respective classes has the methods setAttribute, getAttribute, and removeAttribute so that you can store, retrieve, and delete associated data.

Cookies can also be used to store information other than session IDs. The Cookie class allows you to perform all of the functions related to creating and managing cookies, including setting and changing values or causing a cookie to expire.

    [ Team LiB ] Previous Section Next Section