tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stuart Thiel <stuart.th...@gmail.com>
Subject Re: How to cast String to int in EL?
Date Tue, 20 Aug 2019 07:48:53 GMT
Ah, it is parameter casting you're after. That was unclear from your
initial request. What does:
<sql:param value="${0 + param.member_id}"/>
yield?





On Tue, Aug 20, 2019, 02:07 Kazuaki Miyauchi <miyauchk@gmail.com> wrote:

>  Hi, Stuart
>
> 2019-08-19 20:32 GMT+09:00, Stuart Thiel <stuart.thiel@gmail.com>:
> > I can't speak to Tomcat 5, that's been years. However, the code you're
> > using is not passing an integer. If you take a look at the generated
> > Java source (which is a mess with taglibs) you may see why. Once more,
> > a quick google suggests some solutions, in particular, the trivial
> > one: <sql:param value="${1}"/>
>
>  Following source works correctly, of course.
>
> <c:set var="member_id" value="1"/>
> <% int member_id = (int)session.getAttribute("member_id");
>    session.setAttribute("member_id_num", member_id); %>
> <sql:setDataSource dataSource="jdbc/kome" var="kome"/>
> <sql:update var="stmt" dataSource="${kome}">
>  insert into test values(?,?)
>  <sql:param value="${member_id_num}"/>
>  <sql:param value="Miyauchi"/>
> </sql:update>
>
>  Ordinary we get HTTP request parameter via EL using ${param.hogehoge}.
> So, It's troublesome to write following.
>     int member_id = Integer.valueOf(request.getAttribute("member_id");
>     session.setAttribute("member_id_num", member_id);
>
>  Instead of <sql:param value="${param.member_id}"/>
>
>  Isn't there more convenient way?
>
>  Regards,                             Kazuaki Miyauchi, Japan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: taglibs-user-help@tomcat.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message