文档介绍:65chapter3Chapter 3Advanced Servlet TechniquesIn This Chapter?Using sessions and storing state?Using cookies for long-term storage?Filtering HTTP requests?Understanding WebLogic Server deployment issues?Additional best practices for Web application developmentChapter 2 discusses the basics of handling HTTP requests and how to manage collections of Webresources. This chapter takes servlets a step further and discusses how to maintain informationbetween HTTP requests, how to improve code reuse with filters, and how to plan Web applicationdeployments on WebLogic to improve performance and and Web SessionsThe Hypertext Transfer Protocol (HTTP) is, by design, a stateless protocol. However, many Webapplications require information, previously gathered from the user, to process a request. With thisinformation, a servlet can remember a user’s name, items placed in a shopping cart, or a shippingaddress. The notion of saving information across multiple requests from a single client is typicallycalled a Web session. Linking this information from one request to another is session Information in a SessionIn the early days of the Web, developers found many ways to maintain session information. Brows-ers and servlet containers provided different mechanisms to store, retrieve, and track informationfrom one request to the next. Developers had to create their own session management , the servlet standard defines mon mechanism to maintain sessions. monmechanism, the servlet session, hides most of the plexities and allows developers toconcentrate on writing Web applications. Servlets place information into a session and retrieve thisinformation in subsequent requests. In this way, sessions add state information to the otherwisestateless HTTP Page 65 Monday, April 19, 2004 11:45 AM66Chapter 3 ? Advanced Servlet TechniquesSessions work by storing state information in a local object and creating a reference to tha