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 23:55:22 UTC

whats up with sql:param

  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


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


Cannot pass get variable to the sql:param, still same

Posted by Gokhan <go...@mira-soft.com>.
Hello All,

I already tested with this setting before i post this mail.
Very interesting error i have in here. Still have the same reults.
I tried also go back to old version of JSTL too.
Any JSTL developer around?

Take care
Gokhan



Martin Cooper wrote:

>The first thing I would try is taking everything out of the
><sql:update> except the query string itself and the <sql:param>
>element, so that you're left with:
>
><sql:update dataSource="jdbc/zobarenk">
>    insert into test_table (testnumber_id) values (?)
>    <sql:param value="${param.testnumber}"/>
></sql:update>
>
>--
>Martin Cooper
>
>
>On 6/16/05, Gokhan <go...@mira-soft.com> wrote:
>  
>
>>  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
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>
>>
>>    
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>
>
>  
>


Re: whats up with sql:param

Posted by Martin Cooper <mf...@gmail.com>.
The first thing I would try is taking everything out of the
<sql:update> except the query string itself and the <sql:param>
element, so that you're left with:

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

--
Martin Cooper


On 6/16/05, Gokhan <go...@mira-soft.com> wrote:
>   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
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
> 
>

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