Comparing param with String (made from sql query return)
I have a problem, im trying to create a form which sends paramaters to a process page, this then inserts into the database. However I want to pick up duplicate name entries and im trying to do it like so without any luck:
<sql:query var="pgeDupTestName" scope="request">
SELECT dbTestName FROM test
</sql:query>
<c:forEach items="pgeDupTestName.rows" var="myRow">
<c:set var="holder" value="${myRow.dbTestName}" scope="page"/>
<% String tostr = pageContext.findAttribute("holder").toString();%>
<c:if test="${tostr == param.frmTestName}">
<c:set var="reqDuplicateName" scope="request" value="Test Name must be unique" />
<c:set var="reqOutcome" scope="request" value="failure" />
<jsp:forward page="/WEB-INF/jsp/cwjsps/uc024v.jsp"/>
</c:if>
</c:forEach>
I firstly run an SQL query to select all test names then I go through a for loop, looping through each one of these and each time converting it to a string using a java expression but then when I try compare that string to the paramter set they do not bring back true, always false. However if I change this line:
<c:if test="${tostr == param.frmTestName}">
to..
<c:if test="${tostr != param.frmTestName}">
be NOT EQUALS it returns true and the code inside the if statement executes? I don't get why the strings arn't the same, someone help ;[
Message was edited by:
tranquility2k4

