Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help Regarding about Session in jsp

 
Santhana Lakshmi.S
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

I am developing one web page in jsp. here i have some doubt in session tracking for all pages.

can u tell me proper use of session tracking in all web pages.for example if u would like to use of username with all pages.

how to use this username account in session tracking without reflecting another username account datas.

thanks a lot
 
Santhosh Kumar
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry that I'm not getting what is your doubt in the session tracking. Nevertheless I try what I can answer.

First of all, you seem very new to the Web application development. Eventhough friends here at javaranch are friendly enough to answer your questions, I would strongly suggest you to read a generic book on web application development which would explain very clearly.

To implement session for sets of pages:

1. Before accessing every page, check if there is a active session
2. If session is not there, redirect to login page
3. After user submits the login name/password, validate and create a session
4. Show the page.

In jsp you can just use the session variable to access the current session. Note that if there was no session for a user, system would automatically creates one. So to check if user logged in or not, you should check for some predefined value is stored in the session or not.

(If you session session="false" in the page directive, then jsp engine would not create a session varialbe. Then you can use the request.getSession(false) or request.getSession(true)) methods to control the session.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic