This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Confusion in Session tracking

 
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 !!
 
He loves you so much! And I'm baking the cake! I'm going to put this tiny ad in the cake:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!