01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tctest.webapp.servlets;
05:
06: import com.tc.object.bytecode.Manageable;
07:
08: import java.io.IOException;
09: import java.io.PrintWriter;
10:
11: import javax.servlet.http.HttpServlet;
12: import javax.servlet.http.HttpServletRequest;
13: import javax.servlet.http.HttpServletResponse;
14: import javax.servlet.http.HttpSession;
15:
16: public final class SessionObjectIdentityTestServlet extends HttpServlet {
17:
18: private static volatile HttpSession s = null;
19:
20: public void doGet(HttpServletRequest request,
21: HttpServletResponse response) throws IOException {
22: HttpSession session = request.getSession(true);
23: PrintWriter out = response.getWriter();
24:
25: if (request.getRequestedSessionId() == null && session.isNew()) {
26: if (s != null) {
27: out.println("static field is non-null");
28: }
29:
30: s = session;
31: out.println("OK");
32: return;
33: }
34:
35: if (s != s) {
36: out
37: .println("session object is different reference on second request");
38: return;
39: }
40:
41: // Make sure that session object is portable and shared
42: s.setAttribute("the session", s); // tests portability of session object
43: if (!((Manageable) session).__tc_isManaged()) {
44: out.println("session object itself is not a shared object");
45: }
46:
47: out.println("OK");
48: }
49:
50: }
|