2 Replies Latest reply on Sep 16, 2012 5:03 PM by nickarls

    Getting Object from session in JSTL

    yesitsgauravgoel

      Hi,

       

      I am trying to fetch the object from Session in JSTL tag but the the data is not coming in the JSP. Below is the code of JSTL in JSP.

       

      <c:forEach items="${userSessionInfo.nodeTypes}" var="node">

          <tr bgcolor="#FFFFFF">

            <td>

            <a href="<c:url value="view_instance_for_nodetype.do"><c:param name="workingNodeId" value="${node.nodeTypePk}"/></c:url>">

              <c:out value="${node.nodeType}"/>

            </a>

             </td>

          </tr>

      </c:forEach>

       

      Below code is where I am setting the user seesion object in session object and JSP page name is landing.jsp.

       

                  nodeTypes = nodeConfigService.getAllNodeTypes();

                  userSession.setNodeTypes((ArrayList) nodeTypes);

                  request.getSession().setAttribute("userSessionInfo", userSession);

                  request.setAttribute("userSessionInfo", userSession);

                  modelAndView.setViewName("landing");

                  return modelAndView;

       

      I am using JBOSS 7.0.2 version and JSTL 1.2 but still in JSP the JSTL could not able to render it . I am getting ${node.nodeType}  in JSP instead of the Actual Value.

       

      Any Idea what I am doing wrong? The same code is working fine in Tomcat 6.0.

        • 1. Re: Getting Object from session in JSTL
          ssilvert

          I think you'll have to do some debugging to find the answer, but browsing at your code I see one odd thing.  You are setting the same attribute name at both request and session scope.  EL resolution will only find one of them and I'm pretty sure it will find the one at request scope.

           

          request.getSession().setAttribute("userSessionInfo", userSession);
          request.setAttribute("userSessionInfo", userSession);
          

           

          Stan

          • 2. Re: Getting Object from session in JSTL
            nickarls

            But since you go into the loop, apparently you are getting *some* EL-resolving. If you view the source, the c:param is not resolved either?