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

[2087 byte] By [tranquility2k4a] at [2007-11-26 19:32:44]
# 1

I realised there was a mistake in syntax:

<c:forEach items="${pgeDupTestName.rows}" var="myRow">

didn't put expression around items =""

Still getting same problem though, I don't understand why tostr doesn't == the parameter

Message was edited by:

tranquility2k4

tranquility2k4a at 2007-7-9 22:04:18 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

OMG, resolved it! didn't even need the java expression there I could just compare the current set variable with the parameter, and it obviously didn't work before because I had a syntax error! Argh..

<c:forEach items="${pgeDupTestName.rows}" var="myRow">

<c:set var="holder" value="${myRow.dbTestName}" scope="request"/>

<%--<% String tostr = pageContext.findAttribute("holder").toString();%>--%>

<c:if test="${holder == 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>

Theres new version with the java line commented out. Still a mystery as to why it's so hard to use java strings straight into expressions.

tranquility2k4a at 2007-7-9 22:04:18 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...