tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kief Morris <>
Subject Re: Creating & Maintanin Sessions using Tomcat 3.2
Date Fri, 09 Feb 2001 10:55:52 GMT
Pravin Jain typed the following on 03:42 PM 2/9/2001 +0500
>Tomcat is configured perfectly ok and is running fine. The only problems I
>have is while implementiong  "Session" in my servlets. I have a servlet say
>"First" servlet, that create's an Httpsession using the getSession() method
>and uses the setAttribute() method to bind/set the object in the session.
>Below is an example code that I write in doPost()/doGet() method to create
>a Session is servlet "First":
>HttpSession session =  request.getSession();
>String usrid = "tomcat";
>Now in another servlet, lets call it "Second" servlet, when I try to create
>a session and extract the value that is set in the above code, it throws a
>NullPointerException, meaning that it did not find the session, which was
>successfully created in the First servlet.
>Example code in "Second" servlet to get the values bound/set in the session
>created by the "First" servlet:
>HttpSession session =  request.getSession(false);
>String test = (String) session.getAttribute("Userid");
>The above line throws a NullPointerException. 

Are you sure the cookie is being set? Set your browser to warn you when cookies
are set by the server.

Are both servlets in the same webapp?


View raw message