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";
>session.setAttribute("UserId",usrid);
>
>
>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?

Kief


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to