Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Confusion in Session tracking  RSS feed

 
shivang sarawagi
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created a User Registration servlet, saved the username in a session & displayed in the UserHomePage.jsp
by session.getAttribute("username");

Now when I am logging in with the same user credentials by a User Login servlet
I am again saving the username in a session and want to display username in UserHomePage.jsp

So do I have to put session.getAttribute() again in the UserHomePage.jsp ???
 
Aniket Khadke
Greenhorn
Posts: 29
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shivang sarawagi wrote:I created a User Registration servlet, saved the username in a session & displayed in the UserHomePage.jsp
by session.getAttribute("username");

Now when I am logging in with the same user credentials by a User Login servlet
I am again saving the username in a session and want to display username in UserHomePage.jsp

So do I have to put session.getAttribute() again in the UserHomePage.jsp ???


Shivang do you want to display username two times? if not a single session.getAttribute should work
 
shivang sarawagi
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So that means no matter in how many Servlets I save the username in a session. I just need a single session.getAttribute() to display the username ??
 
Aniket Khadke
Greenhorn
Posts: 29
Eclipse IDE Java Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shivang sarawagi wrote:So that means no matter in how many Servlets I save the username in a session. I just need a single session.getAttribute() to display the username ??


exactly, because at a time you are going to display only one username. getAttribute method will return the value of current session only..
 
shivang sarawagi
Ranch Hand
Posts: 159
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Aniket !!
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!