aspose file tools*
The moose likes Struts and the fly likes How to get Arraylist in jsp page to render Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to get Arraylist in jsp page to render" Watch "How to get Arraylist in jsp page to render" New topic
Author

How to get Arraylist in jsp page to render

jaan bhavsar
Ranch Hand

Joined: Aug 23, 2008
Posts: 32
Hi to All,
I am trying to make sample application and cant pass arraylist object on jsp page.
Could any body please guide me regarding to that?

Which will populate my arraylist(emplist) in ListDb class.
I call this method from ListAction.
//code for ListAction

How can i put Arraylist emp in request,and get arraylist object on Jsp page?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Provide a public getter for the list and it's available in the JSP.

Note that you're creating a new ArrayList then promptly replacing it with another one--you might as well skip the unused constructor call.

I'd also consider doing something different than instantiating the ListDB() directly, although it may not be very important yet--it can impede testability and flexibility, though.

(And is an empty list actually an error? It might be--but if not, maybe a different result name would express intent better?)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to get Arraylist in jsp page to render