Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

session variables

Posted on 2003-03-14
8
Medium Priority
?
208 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
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Use this step by step method when setting up QuickBooks Online. They will allow you to explore the various features of the advanced settings available to you.
Welcome to 2018! Exciting things lie ahead in the world of tech. To start things off, we compiled great member articles on how to stay safe, ways to learn, and much more! Read on to start your new year right.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses
Course of the Month15 days, 20 hours left to enroll

581 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