tags:

views:

29

answers:

1

I was wondering if anyone would be able to show me how to convert an arraylist to normal array in Jsp?

+1  A: 
yourArrayList.toArray()

but this won't be generic.. to use the generic version, let's assume you've got an ArrayList<Yourclass>. Just do:

YourClass[] array = yourArrayList.toArray(new YourClass[0]);

A side note: JSP is not a language but a container of Java code and html so what you need is Java code..

Jack
Here you created an empty array (new YourClass[0]) which is soon discarded. This would be much better: yourArrayList.toArray(new YourClass[*yourArrayList.size()*]); The same array will be returned.
SiLent SoNG