I have the following code:
<bean:define id="hasDocuments" name="BudgetSimulationDetailForm" property="hasDocuments" type="java.lang.Boolean"/>
<%
request.setAttribute("enablebtnRelatedDocs", "true");
request.setAttribute("hasDocuments", String.valueOf(hasDocuments));
%>
I want to remove the scriptlet, I tried using c:set with different scopes but it didn't work. Is it possible to set a request attribute using JSTL tags?
I tried this and did not work:
<c:set name="enablebtnRelatedDocs" value="true" scope="request"/>
and also
<c:set name="enablebtnRelatedDocs" value="${true}" scope="request"/>
Afterwards there is an include:
<jsp:include page="/gema/jsp/includes/detail/top_Detail.jsp">
<jsp:param name="title_key" value="${title}" />
<jsp:param name="title_bundle" value="buc" />
<jsp:param name="standard_buttons_include" value="true" />
<jsp:param name="typeId" value="53555" />
<jsp:param name="detail" value="budget" />
</jsp:include>
Inside the included JSP the request attribute is not visible, apparently.
Sounds Good, You want to use JSP Standard Tag Library instead of Scriplet.
Yes, It's possible using c:set
. Read more about Core Tag Library
<c:set var="enablebtnRelatedDocs" value="${true}" scope="request"/>
<c:out value="${requestScope.enablebtnRelatedDocs }"/>
By default c:set
set a attribute in page context. you can set it in any scope.
By default, the JSTL Core library function "set" accepts the following attributes:
JSTL Core set property (credits to tutorialspoint.com) : value, target, property, var, scope
You should use "var=" instead of "name=". Hope this helps!
Happy coding! 1:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With