?
Solved

session variables

Posted on 2003-03-14
8
Medium Priority
?
204 Views
Last Modified: 2010-04-01
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
0
Comment
Question by:bilbo010
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
8 Comments
 
LVL 4

Expert Comment

by:thanassis
ID: 8135501
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!
0
 

Author Comment

by:bilbo010
ID: 8135692
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    
0
 

Author Comment

by:bilbo010
ID: 8135699
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    
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:bilbo010
ID: 8135719
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    
0
 

Author Comment

by:bilbo010
ID: 8135739
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    
0
 
LVL 4

Accepted Solution

by:
thanassis earned 200 total points
ID: 8135811
oh sorry true is boolean :)
So try this:

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

and in the other pages do:

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

Expert Comment

by:kennethxu
ID: 8136568
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" );
0
 

Author Comment

by:bilbo010
ID: 8173291
sorry for the delay few other things to sort thanks all
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hey fellow admins! This time, I have a little fairy tale for you. As many tales do, it starts boring and then gets pretty gory. I hope you like it. TL;DR: It is about an important security matter, you should read it if you run or administer Windows …
If you're a modern-day technology professional, you may be wondering if certifications are really necessary. They are. Here's why.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question