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
2010-10-21 21:35:01
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
2010-10-22 11:14:42