Return-Path: Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 74301 invoked from network); 15 Aug 2000 16:57:35 -0000 Received: from wpo.aamc.org (143.220.4.36) by locus.apache.org with SMTP; 15 Aug 2000 16:57:35 -0000 Received: from aamc.org (U024223.aamc.org [143.220.24.223]) by wpo.aamc.org; Tue, 15 Aug 2000 12:54:59 -0500 Sender: steve Message-ID: <39997618.EDE46B1A@aamc.org> Date: Tue, 15 Aug 2000 12:55:52 -0400 From: Steve Weiss Organization: Association of American Medical Colleges X-Mailer: Mozilla 4.73 [en] (X11; U; Linux 2.2.14-12 i686) X-Accept-Language: en, de, fr MIME-Version: 1.0 To: tomcat-user@jakarta.apache.org Subject: Re: Retrieving Objects from the Session Results in a Null Pointer References: <87F86E5E544FD2119AA400A0C9DD59FE2734FB@allegro.jacobstern.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Rating: locus.apache.org 1.6.2 0/1000/N 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