Reputation: 88
I'm trying to parse a request param in my JSP using tags: <c:if> and <c:set>
The parameter is named result, so my variable in jsp is requestScope["result"]
I have two issues:
I wanna check two cases: param is null or not, I used the following code
<c:if test='${not empty requestScope["result"]}'> <c:set var = "result" value = '${requestScope["result"] }'/> </c:if> <c:if test='${empty requestScope["result"]}'> <c:set var = "result" value = ' not available'/> </c:if>
In order to set the result from request in result variable or "not available" value if it is null
This code always shows not available but when i delete the second test, it shows the result corrctly
Also I tried with '${param.result != null}'
test, it gives the same result.
Thank you in advance
Upvotes: 0
Views: 4411
Reputation: 41
I have similiar code and this way works for me:
<c:set var="result" value="${(requestScope['result'] == null || requestScope['result'] eq '') ? 'not available' : ${requestScope['result']}}"/>
Upvotes: 1