| Author |
Can a JSP page retrieve an array off a bean?
|
Fritz Largosa
Ranch Hand
Joined: Sep 12, 2005
Posts: 70
|
|
Can a JSP page retrieve an array off a bean? I have two sample lines below. The first line retrieves the bean saved by the servlet, the second line displays the value of property x. Now if x returned a array, how can I display all values of the array? How can I loop through all array values of x? Thanks for the help, I'm confuse on this one. <jsp:useBean id="key" type="Package.Object" scope="Application" /> <jsp:getProperty name="key" property="x" />
|
 |
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15230
|
|
|
You'll probably want to look at JSTL for iterating over arrays.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56229
|
|
|
Which version of JSP? Please always include this information when posting a new question.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Fritz Largosa
Ranch Hand
Joined: Sep 12, 2005
Posts: 70
|
|
|
JSP 2.0
|
 |
Fritz Largosa
Ranch Hand
Joined: Sep 12, 2005
Posts: 70
|
|
|
Is there a way to do this in a scriptlet?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56229
|
|
Of course, but if youare using JSP 2.0 that's like using stone knives and bearskins. Being sure that the JSTL 1.1 is set up correctly, and that the c library is mapped on the page, it's as easy as (using the naming in your op):
|
 |
Fritz Largosa
Ranch Hand
Joined: Sep 12, 2005
Posts: 70
|
|
Is it possible to iterate through a two dimensional array in a bean? All samples I see pertain to single dimensional arrays or just one string values. I am needing to convert the code below to JSTL. where array_variable is a two dimensional array. for(int x =0; ${Bean.array_variable[1][x]} != null; x++){ ..... } [ April 11, 2007: Message edited by: Fritz Largosa ]
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
|
You can nest <c:forEach ../> tags.
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
 |
|
|
subject: Can a JSP page retrieve an array off a bean?
|
|
|