| Author |
show dynamic data from array in my jsp
|
Angus Ferguson
Ranch Hand
Joined: Jun 22, 2012
Posts: 240
|
|
Hi if I have an array like listDecreasedUs which comes from my business logic, and I want show it dynamically in my JSP.
What kind of code I need? Something like:
But want do it without scriptlets.
Any idea?
Thanks
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56174
|
|
Use JSTL's <c:forEach> action.
Of course what you are showing there is JavaScript, not Java, so I'm not sure if "scriptlets" is really what you meant. Is it?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Angus Ferguson
Ranch Hand
Joined: Jun 22, 2012
Posts: 240
|
|
I meant Java.
I have not the possibility to debug, that's way I ask you if this code would works. I have saw that in my IDE when I try to use something like countriesReportList.length() the method length() doesn't appears. Am I missing something?
Thanks
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56174
|
|
You can't call general methods in the EL (unless you are using the very latest version).
You also didn't mention what countriesReportList is. A List? An array?
You also don't use .get() in the EL. You use array notation, even if it's a List.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56174
|
|
If countriesReportList is an array or List, the proper syntax would be:
Note that you don't need to keep track of indexes and use array subscripting at all.
|
 |
Angus Ferguson
Ranch Hand
Joined: Jun 22, 2012
Posts: 240
|
|
countriesReport is an array an I want retieve it from the request like this
Is that posbile?
Thanks
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56174
|
|
Angus Ferguson wrote:countriesReport is an array
What happened to countriesReportList? Or did you just change the name?
an I want retieve it from the request like this
I assume that's the code from the servlet controller that creates the scoped variable?
Is that posbile?
Of course. As I said, either an array or List (or even Map) can be iterated over with <c:forEach>
|
 |
 |
|
|
subject: show dynamic data from array in my jsp
|
|
|