I am learning about sessions using JRun 2.3 and IIS4.  When I put Jason
Hunter's code in a doGet that is found on pages 208-209 of his book (This is
the hit count using Session tracking example)  I am getting strange results.

Here is the code at the beginning of my doGet:

                HttpSession session = req.getSession(true);
                Integer 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);

near the bottom of my servlet I have this:

                out.println("SESSION TESTING:  You've visited this page " +
count +
                        ((count.intValue() == 1) ? " time." : " times."));
                out.println("<p>");

When I initially load the page I get " 1 time.".  But if I reload/refresh
the page again it still says " 1 time".  After reloading the page two more
times it, it finally increments to "2 times.".

Am I doing something wrong?

Brad Simonin

___________________________________________________________________________
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