If you open a new window from anywhere outside of the current window then it will create a new session. Closing a window will (usually) close out your current session as well. So closing a window and reopening a new one will usually be the equivalent of starting a new session. -Tim
-----Original Message----- From: Kumar Sameer [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 09, 2002 11:10 AM To: [EMAIL PROTECTED] Subject: Session tracking API Hi ! I am using the class HttpSession for session tracking. I have a simple class which just keeps a count and displays it. When i run it in a browser, and hit refresh button, the count is incremented correctly. But if i open another window, the count restarts from 1. I was expecting that even in the new window, the count will be maintained. The code is : import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.util.*; public class sessionTrackingApiCount extends HttpServlet { PrintWriter out; Integer count; public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); out = res.getWriter(); HttpSession session = req.getSession(true); count = (Integer) session.getValue("tracker.count"); if(count == null) { count =new Integer(1); } else { count = new Integer(count.intValue() + 1); } session.putValue("tracker.count",count); out.println("<HEAD><TITLE> Session Tracking using session tracking API.</HEAD></TITLE>"); out.println("<BODY>"); out.println("You have visited this page " + count + ((count.intValue() ==1) ? "time." : "times.")); out.println("<P>"); out.println("<h2>Your session data : </h2>"); String[] names = session.getValueNames(); for(int i = 0; i < names.length;i++) { out.println(names[i] +" : " + session.getValue(names[i]) + "<BR>"); } out.println("</BODY></HTML>"); } public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { doGet(req,res); } public String getServletInfo() { return " Servlet using session tracking API for session tracking. "; } public void destroy() { } } Can anyone please point out my mistake? Regards Sameer ___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html ___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
