Re: How to cast String to int in EL?

Stuart Thiel <[email protected]> Tue, 20 Aug 2019 04:48:53 -0300
Newsgroups gmane.comp.jakarta.taglibs.user
Message-ID <CAEp2D=6Fv0i7gR8GiS7kwaWk5T6iPhAB1eX8qNyx3=h6PryqnQ@mail.gmail.com>
--000000000000d870a2059087b0b2
Content-Type: text/plain; charset="UTF-8"

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 <[email protected]> wrote:

>  Hi, Stuart
>
> 2019-08-19 20:32 GMT+09:00, Stuart Thiel <[email protected]>:
> > 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: [email protected]
> For additional commands, e-mail: [email protected]
>
>

--000000000000d870a2059087b0b2--