| Author |
Spring: ArrayList instead of <c:forEach in jsp page
|
Imre Tokai
Ranch Hand
Joined: Jun 04, 2008
Posts: 129
|
|
Hello!
I want to use java.util.ArrayList instead of <c:forEach in jsp page, because i need it in javascript
This is working well:
but when i try with:
I get NullPointerException.
How can i use the passed array with java.util.ArrayList in jsp page?
Regards
|
 |
Omar Al Kababji
Ranch Hand
Joined: Jan 13, 2009
Posts: 357
|
|
when you use the ${items} it dosen't mean that the items arraylist is in the request scope it could be in page, request, session, application scopes i would suggest to double check if the items are in the request scope, may be they are in the session scope ;).
remember that when using EL it will go and search for the attribute in any in the following sequence .. page --> request --> session --> application
(peace)
|
Omar Al Kababji - Electrical & Computer Engineer
[SCJP - 90% - Story] [SCWCD - 94% - Story] [SCBCD - 80% - Story] | My Blog
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56554
|
|
Imre Tokai wrote:I want to use java.util.ArrayList instead of <c:forEach in jsp page, because i need it in javascript
This makes little sense. What is it that you are really trying to do?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Imre Tokai
Ranch Hand
Joined: Jun 04, 2008
Posts: 129
|
|
Thanks for your answers!
I tried with page,request,session, application -no success.
I'm using Spring framework; I want to pass an ArrayList of objects to the jsp page via SomeController's handleRequestInternal method.
It's working fine when I'm just writing contents of the objects from list to the page using c:forEach
But when I want to use request.getAttribute("items"); I get exception.
If I'm able to pull the values out with <c:forEach items="${items}" var="item">, why can't I do that with
<% java code parts inside jsp page%>? How can I solve this?
Regards
|
 |
Omar Al Kababji
Ranch Hand
Joined: Jan 13, 2009
Posts: 357
|
|
are you getting a NullPointerException or another type of exception ? can you post the stack trace of the exception please ?
(peace)
|
 |
Imre Tokai
Ranch Hand
Joined: Jun 04, 2008
Posts: 129
|
|
SOLVED!
It seems that it's not possible to have:
on the same page.
I had that foreach for data preview. When i removed it the page started to work correctly.
Thank you for leading me to the solution!
Regards>
|
 |
 |
|
|
subject: Spring: ArrayList instead of <c:forEach in jsp page
|
|
|