When creating a session definition in the Session Definitions section of the

Caching with Third-Party Application Servers 12-7 This software is the confidential and proprietary information of Sun Microsystems, Inc. Confidential Information. You shall not disclose such Confidential Information and shall use it only in accordance with the terms of the license agreement you entered into with Sun. SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. CopyrightVersion 1.0 package sunexamples; import java.io.; import java.util.Enumeration; import javax.servlet.; import javax.servlet.http.; This is a simple example of an HTTP Servlet that uses the HttpSession class Note that in order to guarantee that session response headers are set correctly, the session must be retrieved before any output is sent to the client. public class SessionServlet extends HttpServlet { public void doGet HttpServletRequest req, HttpServletResponse res throws ServletException, IOException { Get the session object HttpSession session = req.getSessiontrue; Get the output stream ServletOutputStream out = res.getOutputStream; res.setContentTypetexthtml; out.printlnHEADTITLE SessionServlet Output + TITLEHEADBODY; out.printlnh1 SessionServlet Output h1; Heres the meat Integer ival = Integer session.getValuesessiontest.counter; if ival==null ival = new Integer1; else ival = new Integerival.intValue + 1; session.putValuesessiontest.counter, ival; out.printlnYou have hit this page b + ival + b times.p; encodeURL Encodes the specified URL by including the session ID in it 12-8 Oracle Fusion Middleware Administrators Guide for Oracle Web Cache if cookies are not turned on or not supported by the browser out.printlnClick a href= + res.encodeURLsession.html + herea; out.println to ensure that session tracking is working even if + cookies arent supported.br; out.println Note that by default URL rewriting is not enabled due + to its expensive overhead.; out.printlnp; out.printlnh3Request and Session Data:h3; out.printlnSession ID in Request: + req.getRequestedSessionId; out.printlnbrSession ID in Request from Cookie: + req.isRequestedSessionIdFromCookie; out.printlnbrSession ID in Request from URL: + req.isRequestedSessionIdFromURL; out.printlnbrValid Session ID: + req.isRequestedSessionIdValid; out.printlnh3Session Data:h3; out.printlnNew Session: + session.isNew; out.printlnbrSession ID: + session.getId; out.printlnbrCreation Time: + session.getCreationTime; out.printlnbrLast Accessed Time: + session.getLastAccessedTime; out.printlnbra href=\examplessimple_servlets\Upa; out.printlnBODY; out.close; } public String getServletInfo { return A simple session servlet; } } To start, perform the following steps: 1. Compile the SessionServlet.java file in the Apache Tomcat environment.