Hi all,
I'm running the example on session tracking (LAB-4004) and I
discovered something very strange. I'm supposed to run the "Carts"
example in the "JSP Examples" project. When I use the following tag in
the carts.jsp file:

<jsp:useBean id="cart" scope="application" class="sessions.DummyCart" /
>

The application crashes as glassfish (I'm using v2) reports a
NullPointerException:

java.lang.NullPointerException
        at sessions.DummyCart.processRequest(DummyCart.java:55)
        at org.apache.jsp.sessions.carts_jsp._jspService
(carts_jsp.java from :80)
        at org.apache.jasper.runtime.HttpJspBase.service
(HttpJspBase.java:109)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:
847)
        ...

I discovered that the vector has no values in it and that is what is
making the application to crash. I changed the useBean tag to session
scope: <jsp:useBean id="cart" scope="session"
class="sessions.DummyCart" /> and the application works as expected.
Even using request scope works, except that the values added
previously to the vector aren't displayed and only the current value
is shown (as expected).

I closed my browser, and re-started it, then ran the application again
using application scope again and this time I got the following result
after I added 3 items:

You have the following items in your cart:
   1. null
   2. null
   3. null
   4. null
   5. null
   6. null
   7. null
   8. null
   9. null
  10. Beavis & Butt-head Video collection
  11. X-files movie
  12. Twin peaks tapes


Adding more items keeps adding more items to the vector, leaving the
first 9 values as null.

Can anyone please explain what is going on?

Thanks.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Java EE (J2EE) Programming with Passion!" group.
To post to this group, send email to
java-ee-j2ee-programming-with-passion@googlegroups.com
To unsubscribe from this group, send email to
java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to