tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hunter Hillegas <hhille...@jacobstern.com>
Subject RE: Retrieving Objects from the Session Results in a Null Pointer
Date Tue, 15 Aug 2000 17:08:20 GMT
I am sorta new to JSP. I've been doing servlets for quite some time...

I understand that there is a facility to automagically use a session on a
page without declaring it:

<%@ page session="true" %>

instead of doing:

theSession = request.getSession(Boolean);

is declaring in the page a better approach?

As far as using the depreciated method, thanks for the heads up. I'll try
that...


Hunter Hillegas, MCP
Web Engineer / System Administrator - Jacob Stern & Sons, Inc.
hhillegas@jacobstern.com
805-565-1411 PH * 805-565-8684 FAX

 -----Original Message-----
From: 	Steve Weiss [mailto:sweiss@aamc.org] 
Sent:	Tuesday, August 15, 2000 9:56 AM
To:	tomcat-user@jakarta.apache.org
Subject:	Re: Retrieving Objects from the Session Results in a Null
Pointer

Two suggestions:

1. You do have- <%@ page session="true" %> in your JSPs, yes? If not you
won't be able to maintain session information from one page to another.
2. Use session.getAttribute() instead of session.getValue(), which is
deprecated.

-Steve

Hunter Hillegas wrote:
> 
> I have this code:
> 
> <%
> theSession = request.getSession(false);
> 
> shoppingCart cart = null;
> 
> try {
>     cart = (shoppingCart)theSession.getValue("shoppingCart"); //This is
> causing a null pointer exception. Arghhhh...
> }
> catch (Exception e) {
>     e.printStackTrace();
> }
> %>
> 
> that pulls an object out of the session...
> 
> I can verify that the object is in the session. I can grab it from the
page
> I inserted it from with this code:
> 
> shoppingCart testCart = (shoppingCart)theSession.getValue("shoppingCart");
> 
> I just can't get it from any other pages...
> 
> Any ideas?
> 
> Hunter Hillegas, MCP
> Web Engineer / System Administrator - Jacob Stern & Sons, Inc.
> hhillegas@jacobstern.com
> 805-565-1411 PH * 805-565-8684 FAX

-- 
Steve Weiss      Association of American Medical Colleges
(202)828-0428    mailto:sweiss@aamc.org    http://www.aamc.org

Mime
View raw message