I thought I understood the JSP session object, but then I observed the
following behavior. The code that I'm executing is
<br>Attributes:<br>
<%! int count=1; %>
<%= session.getMaxInactiveInterval() %> <br>
<b><%= session.getAttribute("numVisits") %></b>
<% session.setAttribute("numVisits", Integer.toString(count++)); %>
When I open my Web browser, and visit this page, I get
Attributes:
1800
null
Then, when I click Refresh, I get
Attributes:
1800
17
The reason for the number 17 is because I had visited this page sixteen
with the same Browser before closing and reopening the browser. So my first
question is, why do I start with null again whenever I close and reopen the
Web browser (even though the session keeps track of how many times I had
visited the page before newly opening the browser)?
The second question relates to the visiting of the page from a different
computer. I go to another computer on the same LAN. (Call this other
computer "computer B".) I visit the same jsp page using computer B. First
I get the null value, then 2, then 3, then 4. OK - that's what I'd expect.
But then, I go back to the original computer (the one on which I counted
up to 17) and I open my Web browser on that computer once again. This time,
I start out with the value null, but then get the value 5 (the number that
I stopped at when I walked away from computer B). Shouldn't both computers
maintain their own places in the numbering, since a session is specific
to a single computer? That is, when I go back to the original computer,
shouldn't the numbers start from 18, where I left off before?
Thanks.
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets