This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes How to access to an ArrayList from the JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to access to an ArrayList from the JSP" Watch "How to access to an ArrayList from the JSP" New topic
Author

How to access to an ArrayList from the JSP

Johny Harris
Greenhorn

Joined: Jan 01, 2011
Posts: 3
Hiii,

I have the following problem:
I want to show the values of a database in my JSP Page. So far, here are the steps the get the values to my JSP page:

-I created a bean class, where the query to get the values from the database, is executed.
-Then I saved every row of the rows to an ArrayList in form of value objects.
Here is the coding of my bean class:



Can anyone explain me, how to access my ArrayList in the bean class from the JSP page, to iterate and show the values ?
Could anyone provide me an example?

Kind Regards,
Johny Harris
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60817
    
  65

In the page controller (servlet) for the JSP, create a scoped variable in request scope for the List. For example:


Then in the JSP it is a simple matter to iterate over the List with the JSTL's <c:forEach>.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
Don't get me started about those stupid light bulbs.
 
subject: How to access to an ArrayList from the JSP
 
Similar Threads
selectOneMenu from database
jsp and java bean problem
JSTL for loop error
java.lang.ClassCastException
problem in calling a method into jsp