I have the following JSTL code that puts an XML document into the
pageScope.  The <state> tag can be found at 
http://www.servletsuite.com/servlets/statetag.htm and is basically a
<select> with all the states as options. I want parse the options and
compare their values with a comma-delimited list of states from a bean
in the request.  That's later - first I want to just get the list of
states and display them using XPath.

<c:set var="statesHTML">
    <state:state name="state" default="<%=state%>" />
</c:set>

<x:set var="states" select="$statesHTML"/>

This all works fine - and I can print out the states using:

<c:out value="${pageScope.states}"/>

Which results in:

<select name="state"> <option value="AL">Alabama</option> ... </select>

However, if I try to get the <options> with XPath and loop through them
with <x:forEach>, I get the following error.  Here's my code for
obtaining that information:

<x:forEach var="state" select="$states/select/option/*">
<c:out value="${state}"/>
</x:forEach>

java.lang.ClassCastException
        at
org.jaxen.dom.DocumentNavigator.getChildAxisIterator(DocumentNavigator.j
ava:172)
        at
org.jaxen.expr.iter.IterableChildAxis.iterator(IterableChildAxis.java:82
)
        at org.jaxen.expr.DefaultStep.axisIterator(DefaultStep.java:139)
        at
org.jaxen.expr.DefaultLocationPath.evaluate(DefaultLocationPath.java:188
)
        at
org.jaxen.expr.DefaultPathExpr.evaluate(DefaultPathExpr.java:156)
        at
org.jaxen.expr.DefaultXPathExpr.asList(DefaultXPathExpr.java:107)
        at org.jaxen.BaseXPath.selectNodesForContext(BaseXPath.java:716)
        at org.jaxen.BaseXPath.selectNodes(BaseXPath.java:239)
        at
org.apache.taglibs.standard.tag.common.xml.XPathUtil.selectNodes(XPathUt
il.java:254)
        at
org.apache.taglibs.standard.tag.common.xml.ForEachTag.prepare(ForEachTag
.java:90)
        at
javax.servlet.jsp.jstl.core.LoopTagSupport.doStartTag(LoopTagSupport.jav
a:262)
        at
org.apache.jsp.userForm_jsp._jspx_meth_x_forEach_0(userForm_jsp.java:165
6)
        at
org.apache.jsp.userForm_jsp._jspService(userForm_jsp.java:560)

I'm deploying the following JSTL JARs in WEB-INF/lib:

jaxen-full.jar
jstl.jar
standard.jar

Environment:
Tomcat 4.1.27
JDK 1.4.2
Windows XP

Thanks,

Matt



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to