File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes new session while refreshing the page. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "new session while refreshing the page." Watch "new session while refreshing the page." New topic

new session while refreshing the page.

prateekprateek narang

Joined: Dec 13, 2003
Posts: 1
hi group,
i've one login.jsp file where i'm creating a new session and setting the inactive time to 10 seconds. the code for this is

after that i forward the page to test1.jsp

my problem is that when i reach this test1.jsp page and leave it inactive for 10 seconds and then refresh, it prints "making new session". could any body tell me why it happens???
i also have test2.jsp. and i reach on this file by clicking on the anchor provided in test1.jsp.

which shows the perfect results. why it happens at one file while another file shows the perfect results.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13028
I'm not sure that I understand what your problem is, but in the first case, the session is new because it was just created. The isNew method returns true which the ! reverses so you see the else output "making new session".
The session won't be considered "old" unless it has been recovered by the servlet engine using a cookie from the browser.
I agree. Here's the link:
subject: new session while refreshing the page.
It's not a secret anymore!