PATRICK
This type of problem i faced earlier.
Actually sometimes it gives null value and sometime it does not
so a better way is to check for length of the field itself like this
pepoleid.length()<2 if pepoleid will null it will throw a nullpointer excep.
and if it is not null but does not contain anything you can adjust your logic
for it
ie :
try{
if(pepoleid.length()<2)
//ur statement here "nobody logged" etc
}catch(NullPointerException e){ //whatever u want}
Regards
Patrick Fong <[EMAIL PROTECTED]> on 09/24/2001 10:29:42 AM
Please respond to A mailing list about Java Server Pages specification and
reference <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
cc: (bcc: Alok Dubey/JAMNAGAR/RIL)
Subject: Session and cookies
Hi
I have a problem with using session object and cookies with jsps.
The problem is that I have set the session max inactive interval to 5 hours
(300 mins * 60 secs) and after a certain time - the shortest being 5 mins,
the session times out. When I access a session variable using people_id =
(String) session.getAttribute("people_id"); I get a nullpointerException.
Anyone here knows whats wrong. Here is a sniplet of my code.
in the login.jsp file
int sessionTime = 300*60; //300 mins session time
session = request.getSession(true);
session.setMaxInactiveInterval(sessionTime);
session.setAttribute((String) "group_id",group_id);
session.setAttribute((String) "role_id", role_id);
session.setAttribute((String) "accessTime", new
Long(accessTime));
in other files
session = request.getSession();
String people_id = (String) session.getAttribute("people_id");
etc etc.
I have used the following function to detect whether the session is null or
not
if (session.getAttribute("people_id")!=null) {
}
else {
throw new Exception("no people access. ");
}
Sometimes this works and other times, a null pointer exception is raised,
eg the 'no people access' is raised. Is this a problem in Resin? Or a
problem with my source?
Patrick
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
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".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
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