I've been given a task to refactor a JSP project, and the last time I coded for JSP was in 2005, a time when we used much more scriptlets, and - AFAIK - there were no Expression Language.
The current page snippet I'm facing is this:
<c:if test="${value.prepphase.exists}">
<div>${value.prepphase.value.status}</div>
<div>${value.prepphase.value.eta}</div>
</c:if>
<c:if test="${value.initphase.exists}">
<div>${value.initphase.value.status}</div>
<div>${value.initphase.value.eta}</div>
</c:if>
<c:if test="${value.legalphase.exists}">
<div>${value.legalphase.value.status}</div>
<div>${value.legalphase.value.eta}</div>
</c:if>
<c:if test="${value.auctionphase.exists}">
<div>${value.auctionphase.value.status}</div>
<div>${value.auctionphase.value.eta}</div>
</c:if>
<c:if test="${value.analysisphase.exists}">
<div>${value.analysisphase.value.status}</div>
<div>${value.analysisphase.value.eta}</div>
</c:if>
Too much repetition, right?
My plan is to build a collection (a list actually) of value.prepphase, value.initphase, value.legalphase, value.auctionphase, value.analysisphase
objetcs, and then:
<c:forEach var="phase" items="${now how to build the list?!?!?!}">
<c:if test="${phase.exists}">
<div>${phase.value.status}</div>
<div>${phase.value.eta}</div>
</c:if>
</c:forEach>
My problem is: how to build the list?
I've tried:
${java.util.Arrays.asList(value.prepphase, value.initphase, value.legalphase, value.auctionphase, value.analysisphase)}
but value
is not available;
[${value.prepphase}, ${value.initphase}, ${value.legalphase}, ${value.auctionphase}, ${value.analysisphase}]
but this yields a list of 5 Strings ("[${value.prepphase}"
, "${value.initphase}"
... "${value.analysisphase}]"
)
I don't know what else to try.
UPDATE
Project's web.xml says <web-app version="3.0">
.