Getting an array from Tag to JSP ????

Discussions

Web tier: servlets, JSP, Web frameworks: Getting an array from Tag to JSP ????

  1. Getting an array from Tag to JSP ???? (2 messages)

    This may be simple but I am missing something here. Your help is appreciated.

    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();
    pageContext.setAttribute("results", res);

    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???

  2. 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.

    Good Luck
  3. 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
    http://www.weblogic.com/docs51/classdocs/API_taglib.html

    Srinivas.J