Hi!!!!!
instead of storing bean as a session object store a variable in the session
to null or anyother value if th user is logged in. Instead of having the
scope of the bean as page change the scope to session. This will solve ur
problem.
And whenever u want to check check for the exsistece of this variable in
the sesson.
Rupali Bains Goswami <[EMAIL PROTECTED]> on 07/15/2000 12:33:15 AM
Please respond to A mailing list about Java Server Pages specification and
reference <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
cc: (bcc: Kher Tamanna-SWD-ITIL-UB/Itilmail)
Subject: problems using session
Jsp Gurus,
I trying to do user authentication by using a java class called
Administrator in my jsp. I need to attach this object to the session so i
can check on each page if this is not null and so the page can be viewed
else send them to the login page.
The code is
<%@ page language="java" import="myBeans.*" %>
<jsp:useBean id="auth" scope="page" class="myBeans.ValidateAdmin" />
<jsp:setProperty name="auth" property="*"/>
<%! String display;
%>
<%
display = "launch.jsp";
try
{
Administrator admin = auth.authenticate();
// check if the user is allowed to view the next page
if (admin != null)
{
out.println("The admin is not null");
session.setAttribute ("administrator",admin);
}
%>
<jsp:include page="nextpage.jsp" />
<%
}
catch (Exception e){}
%>
It works fine till i add the line
session.setAttribute() to add the object in the session. When i do that i
get the following error
Fri Jul 14 13:50:45 EDT 2000:<E> <ServletContext-General> Compilation of
D:\webl
ogic\myserver\classfiles\jsp_servlet\_htdocs\_login3\_logonadministrator.ja
va
fa
iled:
D:\weblogic\myserver\classfiles\jsp_servlet\_htdocs\_login3\_logonadminist
rator.java:122: cannot resolve symbol
symbol : method setAttribute (java.lang.String,myBeans.Administrator)
location: interface javax.servlet.http.HttpSession
session.setAttribute ("administrator",admin); //[
/htdocs/lo
gin3/logonAdministrator.jsp; Line: 22]
^
---------------------------------------
Thanks for the help!
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets