Search code examples
jspjakarta-eejstlstruts-1

How to retrieve a request scoped variable using JSTL on Struts 1


I'm refactoring some legacy code that uses Struts 1 (No flames please), and I am having a difficult time retrieving a parameter I set in my Action class. Here is the code that I'm using in my jsp:

I set the variable submissionFailure in the Action Class, but when I try

<c:out value="${requestScope[cardHolderZipCode]}" />

or

<c:out value="${requestScope.property[submissionFailure]}" />

However nothing is ever output.

I put the following code in my JSP, and I can see the value in the requestScope Map:

<b><i>Request Scope</i></b><br/> <c:forEach items="${requestScope}" varStatus="status" var="parameter"> <c:out value="${parameter}"/><br/><br/>
</c:forEach>

But I still can't get the variable out. Can anyone help me or am I just having an I-D-10-T moment?


Solution

  • It was an I-D-10-T moment on my part. I was trying too hard. Here is the code I ended up using:

    <c:choose>
        <c:when test="${submissionFailure}">
             <%-- Do something --%>
        </c:when>
        <c:otherwise>
             <%-- Do something else --%>
        </c:otherwise>
    </c:choose>