Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding sessions and cookies

 
Santhana Lakshmi.S
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I created one web page in jsp.
In that i want to keep track of the username entered in the login page.

i tried with the following code but it's not working after 3 r more pages
i want to keep track till the user logout.
the code is used is
String name=request.getParameter("username");
session.setAttribute("usernamesession",name);



and in the next page i retrieved
lik this
out.println(session.getAttribute("usernamesession"));
Its working fine in for 3 pages after that it s displaying null value.
can anyone tell me how to keeptrack of the username until the user logout
thanx a lot
 
Heonkoo Lee
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Santhana Lakshmi.S:
Its working fine in for 3 pages after that it s displaying null value.


It could be because of session timed out. Did you check the session-timeout value in web.xml?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64824
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A session timeout is an unlikely culprit as the act of navigating between the pages will reset the session timer. A session timeout will only occur if there a prolonged period of inactivity between actions that exceeds the length of the session timeout value.
 
Heonkoo Lee
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, it is unlikely unless the inactivitity time between navigation is more than time out value.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic