I'm happy with setting properties for my own objects, but how do I do it for a Boolean?! Lets say I do a useBean at the start of some loop and then under certain scenarios I want to then set the boolean to be true (to mark that something was found for example), I want to change the value stored in the bean created by useBean.
I don't want to create a scriptlet, so using JSP tags how would I achieve this?
A quick google search gives me plenty of hits, but not related to my problem. I'm guessing it's related to the fact that the Boolean object isn't a true bean and therefore there's no setter/getter for the boolean value.
What am I overlooking? Can I use the valueOf method to do this? I'm expecting something like this... any pointers?
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@page contentType="text/html" pageEncoding="windows-1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>JSP Page</title>
</head>
<body>
<jsp:useBean id="found" scope="request" class="java.lang.Boolean" />
<h2>Hello World!</h2>
<c:forEach var="current" items="${somethingComplicated}">
<c:if test="${somethingComplicated.someComplicatedMethodThatReturnsTrue}">
<jsp:setProperty name="found" property="valueOf" value="true" />
</c:if>
</c:forEach>
<h2>Value of 'found' is ${found}</h2>
</body>
</html>
Thanks,
Rob.