In at nutshell:
this works and prints on the page:
<%=rsTrusts.getObject("ALPHA")%> <%=rsTrusts.getObject("ACCT")%> <br>
this causes a "no data found" exception:
<input type="checkbox" name="check" value="<%=rsTrusts.getObject("ACCT")%> ">
It's the same code. Why does it fail inside the value expression?
I've also tried this:
<input type="checkbox" name="check" value="<%=rsTrusts.getObject("ACCT").toString()%> "> and that doesn't work either.
Any guesses?
You're getting an SQL exception - could you post some more of the code? What JDBC driver are you using?
if you havn't tried it yet, I'd try storing the value in a String variable and then seeing if you can use it the same way, like:
<%
String checkBoxValue = (String)rsTrusts.getObject("ACCT");
%>
<%=checkBoxValue%><br>
<input type="checkbox" name="check" value="<%=checkBoxValue%>">
My SQL was "select acct, alpha from ledger"
I tried my code above just in the checkbox, without the two fields as text, and that worked.
It seems that in Java, you can't reference the object more than once. It wouldn't have mattered if I had this:
<%=rsTrusts.getObject("ALPHA")%> <%=rsTrusts.getObject("ACCT")%><%=rsTrusts.getObject("ALPHA")%>
without checkboxes, because of the double reference to alpha.
The solution:
I changed the SQL to this: "Select acct, acct as acct2, alpha from ledger"
Then wrote my JSP code as follows:
<input type="checkbox" value="<%=rsTrusts.getObject("acct2")%>">
<%=rsTrusts.getObject("ALPHA")%> <%=rsTrusts.getObject("ACCT")%>
And that worked.
Bizarre.
I've tried to replicate your problem, but can't - I've a feeling it may be behaviour specific to your database driver (I'm using the mm.mysql driver and can reference and re-reference objects in a ResultSet row ad infinitum).
this confuses me though:
It wouldn't have mattered if I had this:<%=rsTrusts.getObject("ALPHA")%> <%=rsTrusts.getObject("ACCT")%><%=rsTrusts.getObject("ALPHA")%>
without checkboxes, because of the double reference to alpha.
If the problem is being able to reference the object more than once, I would expect you to get the same error here. It makes me think I may have misunderstod you?