wood burning stoves 2.0*
The moose likes JSP and the fly likes Scriptlet to JSTL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Scriptlet to JSTL" Watch "Scriptlet to JSTL" New topic

Scriptlet to JSTL

Ola Daniel
Ranch Hand

Joined: Jul 27, 2005
Posts: 105
I use the following code on my JSP:

I want to convert the above to JSTL and avoid the use of scriptlets on the page.
The challenge is how do I convert the foolowing part of the code to JSTL.

I hope my question is clear.

SCJP 1.4, SCWCD 1.4
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
- Martin Fowler et al, Refactoring: Improving the Design of Existing Code, 1999
Ola Daniel
Ranch Hand

Joined: Jul 27, 2005
Posts: 105
I'm not so sure my question above is clear. What I mean is how can i use JSTL
to so something like this:

where index is a variable.
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

This tutorial has example code for the JSTL forEach tag.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ola Daniel
Ranch Hand

Joined: Jul 27, 2005
Posts: 105
Ben thanks for the tutorial link, but i dont need help with the <c:forEach> Tag. What i need help with is the JSTL equivalent of this code:

where index is a variable.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60782

Originally posted by Ola Daniel:

where index is a variable.

What kind of variable? A scriptlet variable or a scoped variable?

If the former, why are you mixing JSTL/EL and scriptlets?

If the latter, then something like:

will do the trick.
[ January 17, 2006: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ola Daniel
Ranch Hand

Joined: Jul 27, 2005
Posts: 105
Thanks Bear, its the latter.

Your post solvs my problem. Thanks.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Scriptlet to JSTL
Similar Threads
jstl + forEach + x number of items per row
JSTL conversion for struts 1.1 code
html checkbox tag and checkall javascript functionality results in undefined alert
How to convert Java ArrayList code to JSTL
On htm:multibox