This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

show dynamic data from array in my jsp

 
Isaac Ferguson
Ranch Hand
Posts: 846
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64980
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Isaac Ferguson
Ranch Hand
Posts: 846
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64980
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64980
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Isaac Ferguson
Ranch Hand
Posts: 846
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
countriesReport is an array an I want retieve it from the request like this




Is that posbile?

Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64980
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic