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

Reply via email to