• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to maintain session for jsp page ?  RSS feed

 
anu sav
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to hide the welcome.jsp page. If we try to access welcome.jsp directly from browser(before doing the login) it should create new session and go to the login page. that is what i want to do. here is my code.



it goes to else part only. and print "welcome null"
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You shouldn't be testing for the session itself. Rather, test for a scoped variable (attribute) that you place in the session upon login.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Be aware that JSP automatically creates a session, unless you specifically put this in the page:

<%@ page session="false" %>
 
anu sav
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but i want to check for pre-existing session. and if there is no pre-existing session then i want redirect this page first for login.jsp
 
Robin John
Ranch Hand
Posts: 281
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thats exactly what the answers mean!

you dont check for pre-existing session but a scope variable within.. if it's not existing.. your pre-existing session isn't either.....
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then you need to add the line I mentioned to the JSP.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!