• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

Confusion in Session tracking

 
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 ???
 
Greenhorn
Posts: 29
Eclipse IDE Tomcat Server Java
  • 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 Tomcat Server Java
  • 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 !!
 
When people don’t understand what you are doing they call you crazy. But this tiny ad just doesn't care:
ScroogeXHTML 8.7 - RTF to HTML5 and XHTML converter
https://coderanch.com/t/730700/ScroogeXHTML-RTF-HTML-XHTML-converter
    Bookmark Topic Watch Topic
  • New Topic