Hi, if the array list is a bunch of value from Java Bean. follow, In action class .... request.setAttribute("sendToJSP",arrayListObj); ... In your jsp page <bean:write name="sendToJSP" property="firstName"/> <bean:write name="sendToJSP" property="middleName"/> <bean:write name="sendToJSP" property="lastName"/> if not bean, use iterator and find the size using <bean:size/> and iterate continuously. that's all Viswa
posted 16 years ago
No, the ArrayList is not a bunch of value from javabean.Rather it is the result of the query which we run.
i.e In ActionClass when i call a method(which runs a query) in DAO, the return type is an ArrayList.
This is the ArrayList which I want to display in JSP
I think now it is clear.
posted 16 years ago
Hi, In Action class ... request.setAttribute("sendToJsp",arrayListObj); ... In JSP page ... <logic:iterate id="myIter" name="sendToJsp"> <bean:write name="myIter"/> </logic:iterate> For example, Your arrayListObj contains firstname,midname,lastname,mailid. here in jsp page logic:iterate iterate the loop depends upon the size of the arraylist object. So this 'll iterate 4 times according to our example. bean:write gives values from that array list. Try this. Regards, Viswa
U have told the the arraylist contains the dataobjects from the query.So it may conatain many objects .
There r Three ways to disaply them on JSP
1:> Is simple iterate .But if u r using Struts framework it will disobey the laws of MVC. So this should not be done if Struts is used
2:> Use Logic:Iterate and print the values by bean:write but if the records r more it will dispaly all in single page that will be mess .
3:> Use Dispaly Which have the inbuild iterator in them and gives u the choice of no. of pages to be dispalyed per page.For theis taglib u have to give just the name of the list and it will iterate it for u.
Originally posted by Vineela Devi Jakka: In ActionClass i have an ArrayList which holds the dataObjects.(Data Object has no of fields like Name, Age, Qualification etc).How can i display all these fields in my JSP.
Please try this code and see if it gives what you requireHTH. Please post back for further query.