aspose file tools*
The moose likes JSP and the fly likes show dynamic data from array in my jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "show dynamic data from array in my jsp" Watch "show dynamic data from array in my jsp" New topic
Author

show dynamic data from array in my jsp

Isaac Ferguson
Ranch Hand

Joined: Jun 22, 2012
Posts: 351
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: 61198
    
  66

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?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Isaac Ferguson
Ranch Hand

Joined: Jun 22, 2012
Posts: 351
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: 61198
    
  66

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: 61198
    
  66

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

Joined: Jun 22, 2012
Posts: 351
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: 61198
    
  66

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>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: show dynamic data from array in my jsp