This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Scriptlet to JSTL" Watch "Scriptlet to JSTL" New topic
Author

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
Sheriff

Joined: Dec 11, 2004
Posts: 13410

This tutorial has example code for the JSTL forEach tag.
http://java.sun.com/developer/technicalArticles/javaserverpages/faster/


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:

request.getAttribute("analy"+index+"_code_options")
where index is a variable.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

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.
 
wood burning stoves
 
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