Link to home
Start Free TrialLog in
Avatar of bilbo010
bilbo010

asked on

session variables

Hi

I have a jsp login page with a basic structure of:

  Enter password and userName
 
  if (password == password in data base){
      set session variable
  }

  if session variable set{
     display menu of site links
  }
Could someone please explain how you set the session variable.  And check for it in this and other site pages.....

Many Thanks in advance
Avatar of thanassis
thanassis

if (password == password in data base)
     session.setAttribute("isLogin", true);

and in the other pages do:

if(session.getValue("isLogin") == null)
   response.sendRedirect("login.html");

Hope that helps!
Avatar of bilbo010

ASKER

Hi

thanks for the help am getting this error
in javax.servlet.http.HttpSession cannot be applied to (java.lang.String,boolean)
session.setAttribute("islogin", true);

Thanks    
Hi

thanks for the help am getting this error
in javax.servlet.http.HttpSession cannot be applied to (java.lang.String,boolean)
session.setAttribute("islogin", true);

Thanks    
Hi

thanks for the help am getting this error
in javax.servlet.http.HttpSession cannot be applied to (java.lang.String,boolean)
session.setAttribute("islogin", true);

Thanks    
Hi

thanks for the help am getting this error
in javax.servlet.http.HttpSession cannot be applied to (java.lang.String,boolean)
session.setAttribute("islogin", true);

Thanks    
ASKER CERTIFIED SOLUTION
Avatar of thanassis
thanassis

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
session.getValue is deprecated. your need
session.getAttribute(), it also may be easier to save username in the session so you can check who is logged on later:
session.setAttribute( "loginUser", username )
if( session.getAttribute( "loginUser" ) != null )
you can also retrieve back username in other page:

String username = (String) session.getAttribute( "loginUser" );
sorry for the delay few other things to sort thanks all