It seems to be a function of the browser. I'm using IE 6 and
Netscape 6.2.1 on Win 2k.

If you start a new instance of IE by pressing CTRL-N, it seems to
send the cookie (i.e., session) to the server. If you start a new
instance of IE by, say, double-clicking the IE icon on the
desktop, and then you paste in the URL, it does *not* send the
cookie. It seems to me like it should. Of course, I assume you
have cookies enabled.

Using Netscape, it *always* seems to send the cookie correctly
whether you start it by CTRL-N or by double clicking the Netscape
icon.

It would be interesting to see what other browsers/platforms
yield, but I think the behavior you're seeing is specific to IE.
There's nothing wrong with your code, as far as I can tell. It's
rather nice, actually. :)



----- Original Message -----
From: "Kumar Sameer" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, April 09, 2002 10:10 AM
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

Reply via email to