KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tctest > performance > servlets > SanityCheckServlet


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tctest.performance.servlets;
5
6 import java.io.IOException JavaDoc;
7
8 import javax.servlet.http.HttpServlet JavaDoc;
9 import javax.servlet.http.HttpServletRequest JavaDoc;
10 import javax.servlet.http.HttpServletResponse JavaDoc;
11 import javax.servlet.http.HttpSession JavaDoc;
12
13 public class SanityCheckServlet extends HttpServlet JavaDoc {
14   protected void doGet(HttpServletRequest JavaDoc req, HttpServletResponse JavaDoc res) throws IOException JavaDoc {
15     HttpSession JavaDoc session = req.getSession();
16     res.getWriter().print(session.getId());
17     
18     String JavaDoc val = (String JavaDoc) session.getAttribute("count");
19     if (val == null) val = "0";
20     
21     res.getWriter().print("count=" + val);
22     
23     int count = Integer.parseInt(val);
24     session.setAttribute("count", "" + ++count);
25   }
26 }
27
Popular Tags