Web tier: servlets, JSP, Web frameworks: Getting an array from Tag to JSP ????
This may be simple but I am missing something here. Your help is appreciated.
- Posted by: Vipul Sagare
- Posted on: March 15 2001 17:34 EST
I am trying to use arrays as scripting variables I have tag usage like this.
<et:getresults id="results" type="mypackage.MyResultPairs" testNo="<%=testno%>"/>
In the tag, I have results as array
mypackage.resultpairs res = someClassInstance.getResults();
I do not get variable in JSP as array. If I define id in tag as array, I get ClasscastException.
What would be correct method to get arrays from tag to JSP???
You are calling pageContext.setAttribute(String name, Object o). The String you are passing is an array of Strings. Even though the Strings are Objects, the array its self is not. If you store the Strings in the collections ArrayList instead, you will be able to pass the ArrayList to the setAttribute method.
Another method is to use the TagExtraInfo class and declare the variables you are going to access in the jsp.
For more info refer the bottom part of