> Oh boy, I get to contribute after asking a lot of questions!  ; )
> 
> Here's a query I am using in a current project:
> 
> <sql:query var='picks' maxRows='1'>
>    select * from contestant_picks where contestant='q' and week = ? 
> order by entered desc
>    <sql:param value='${thisWeek}'/>
> </sql:query>

It's good to know I'm not alone in using JSTL :-)

> I am using the maxRows option mainly because I don't need the db 
> returning all of the older data. Hmm, now that I think about it I can 
> probably add "and entered = max(entered)" or something like that. 
> Anyway, what I learned was that . and [] differed in an important way. 
> You can't evaluate a variable after the . but you can inside the []. As 
> a result my code worked out to:
> 
>    <c:set var='gameNum' value='game${game.game}'/>
>    <c:set var='thisPick' value='${picks.rows[0][gameNum]}'/>
> 
> The gameNum variable will contain a string like "game1", "game2', etc. 
> These are the names of the columns in the table. The second line 
> replaces the gameNum variable inside the [] so I get the equivalent of 
> "picks.rows[0].game1". One other piece you are missing is "rows" from 
> the value. As a result the following code should work for your 
> situation:
> 
> <c:out value='${superData.rows[0][user_id]}'/>

Yes, I noticed that in the afternoon - silly me!

> I would highly recommend the book "core JSTL Mastering the JSP Standard 
> Tab Library" by David M Geary from Sun. It got me up to speed on JSTL 
> in less than a week. Now I can't wait for Tomcat 5 to support JSP 2.0.

Thanks for the advice.

Nix.

Reply via email to