session problems.....

Hoi all,

I've been working on this shopping cart thing for a while now and I finally got it working this morning?.once

I use a list to store the objects the user has selected to buy, and I place the list in the user session scope

here is the funny thing every now and again it works sometimes the cart gives me a null pointer exception and sometimes it works.

what am I doing wrong, I place the list in the user session scope when he/she clicks on the open shop button, which opens an action class that forwards to a JSP that displays the shop items in a dynamically created table.

this is how I place the array list in the session scope:

if(request.getSession().isNew())

{

shpCart =new ArrayList();

request.getSession().setAttribute("shpCart",shpCart);

}

am I doing it right?

Or is there some thing I抦 missing here?

Thanks in advance

[1067 byte] By [Wernsa] at [2007-10-2 4:05:26]
# 1
You'll get more/better replies if you post the exception error message & the corresponding code. A more general answer is that null pointer exceptions are almost always caused by trying to use uninitialized variables.
Dick_Adamsa at 2007-7-15 23:28:10 > top of Java-index,Java Essentials,New To Java...
# 2
Ok will do next time but for now i have sorted it out, cant refer to some thing that is not there :-)
Wernsa at 2007-7-15 23:28:10 > top of Java-index,Java Essentials,New To Java...