Strange problem with session when using jsp:include


Web tier: servlets, JSP, Web frameworks: Strange problem with session when using jsp:include

  1. Hi all,
    I have jsp page which includes 2 jsps. The problem that though the jsp:iclude is able to see the session values the second one is not able to see it.
    Here is a jsp code snippet for the jsp:
    <%@ page import="java.util.*,testing.beans.ProductBean,testing.beans.CartItem;" %>
    <tr height=10%>
    <td colspan=2 align=center>
    Hi <%= (String)session.getValue("customerName")%>!
    Select any of our products and add them to your cart.
    <tr height=90% >
    <td width=50% colspan=1 valign=center>
    <jsp:include page="/jsp/ShowProducts.jsp"/>
    <td colspan=1 width=50% valign=top>
    <jsp:include page ="/jsp/ItemsPurchased.jsp" />

    Here for first jsp:include i have products in the session and i am able to see them. But in the jsp:include which tries to look up items purschased is not able to see the list of items put in the session.
    Interestingly if i include using the include directive the session has values. Also works with pageConext.include().
    When i do session.getValue() in the second jsp:include it gets the non null list but the list is empty with 0 objects in it. So it is not that session is died completetly. Also i checked my code thoroughly i am not removing or clearing the list.
    My question is when the same jsp page would work for an include directive why not for a jsp:include.
    If anyone has gone through the same situation or have a clear picture of what is going on here please explain me. Thanks in advance.


    Threaded Messages (1)

  2. uhm[ Go to top ]

    Shouldn't you be using getAttribute and not getValue?

    getValue has been deprecated for awhile now...