You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Gokhan <go...@mira-soft.com> on 2005/06/16 22:37:11 UTC

whatsup - sql:param values are mysteriously null

Hello,

I just need to approve just something in site without disturbing general 
MVC logic.
And decided JSTL sql:query facility.

I am in test.jsp and i can send user to another page with
<a href="another_page.jsp?testnumber=2">Another Page</a>
And on another_page.jsp i just need to insert this testnumber to table 
as a parameter.

I can see the value with <c:out value="${param.testnumber}"/>. yes 
exactly i can see the number 2 on there.
it means i can get this value from param.testnumber right?

When i want to assign this value to sql query

<sql:update dataSource="jdbc/zobarenk">
insert into test_table (testnumber_id) values (?)

<fmt:parseNumber var="roll" value="${param.testnumber}"/> //Since it is 
integer
<sql:param value="${roll}"/>

or with <sql:param><%request.getParameter("testnumber");%></sql:param>
or with <sql:param><c:out value="${param.testnumber}"/></sql:param>
or assign variable directly to the page scope and get it from there with
<c:set var="testnumber_sucks" value="${param.testnumber}" scope="page" />
<sql:param value="${pageScope.testnumber_sucks}"/></sql:update>

At the end of the all bloody ways i tried, i have this lovely error;
ERROR: null value in column "testnumber_id" violates not-null constraint
Because nothing inside of this lovely testnumber variable.
If i could have type conversion error i would be really happy, but i 
have null.

My question is, if this variable param.testnumber is empty or null how
can i see the value of this parameter with c:out ?
If i can see this bloody value how i can't insert it to the table with 
sql:param with the methods above.

Would it be related to _rt stuff or something?
I am using latest jstl 1.1.2 taglibs

Take care all,
Gokhan


Re: whatsup - sql:param values are mysteriously null

Posted by Rahul Akolkar <ra...@gmail.com>.
On 6/16/05, Gokhan <go...@mira-soft.com> wrote:
<snip/>
> ERROR: null value in column "testnumber_id" violates not-null constraint
> Because nothing inside of this lovely testnumber variable.
> If i could have type conversion error i would be really happy, but i
> have null.

I guess you've tried the simplest way?

<sql:update dataSource="jdbc/zobarenk">
  insert into test_table (testnumber_id) values (?)
  <sql:param value="${param.testnumber}"/>
</sql:update>

-Rahul

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org