Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

help with JSTL xml tags & tomcat

obinnahenreeAug 16 2008 — edited Aug 16 2008
hi, m learning JSTL and the core tags all work fine, but the xml tags throw the folowing exceptions while i try to deploy the JSP where i used them. i am using tomcat 5.5x and i also tried it tomcat 6.0x and same probs.
any suggestions will be welcomed. Sample code and exception below:

<%@ page contentType="text/html" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml" %>
<html>
<body bgcolor="lightblue">

<c:import url="books.xml" var="url" />
<x:parse xml="${url}" var="docs" />

---------------------------------<br>

<x:forEach var="n" select="$docs/books/book" >

<x:out select="n/title" /><br></br>
<x:out select="n/author" />
<br>========================

</x:forEach>

</body>
</html>

org.apache.jasper.JasperException: org/apache/xpath/XPathException
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:460)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

Comments

800345
Shouldn't n/title and n/author be $n/title and $n/author?
obinnahenree
thanks steve, i made the corrections as follows, rather i got this exception this time, code and exception listed bellow:

<%@ page contentType="text/html" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml" %>
<html>
<body bgcolor="lightblue">

<c:import url="books.xml" var="url" />
<x:parse xml="${url}" var="doc" />

---------------------------------<br>

<x:forEach var="n" select="$doc/books/book" >

<x:out select="$n/title" /><br></br>
<x:out select="$n/author" />
<br>============================

</x:forEach>

</body>
</html>

still i get this exception this time


org.apache.jasper.JasperException: An exception occurred processing JSP page /jstl-tut/demo1xml.jsp at line 14

11:
12: ---------------------------------<br>
13:
14: <x:forEach var="n" select="$doc/books/book" >
15:
16: <x:out select="$n/title" /><br></br>
17: <x:out select="$n/author" />


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause

javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/apache/xpath/XPathException
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.jstl_002dtut.demo1xml_jsp._jspService(demo1xml_jsp.java:95)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
843840
java.lang.NoClassDefFoundError: org/apache/xpath/XPathException
Add the mentioned class (or in this case the JAR file with the mentioned class) to the classpath of the runtime environment and you'll be fine.
obinnahenree
thanks balusc, do i search for that on google or ..m kinda new to J2EE stuffs. can u post a url so i can download the required jar.

thanks
800345
Find Xalan. I think it is from Apache.

p.s. If you noticed your first post actually through an "org/apache/xpath/XPathException" but now you get an error that says the class org/apache/xpath/XPathException can't be found! It obviously can be found because when an exception occurred the org/apache/xpath/XPathException was used. This happens because Java 5+ comes with Xalan but renames the packages to be com.sun.org.apache... and the XML tags that come with the Apache standard 1.1 tags don't know that. So you have to get Xalan and put it in the endorsed folder.

BalusC, you had provided a link to Maven and JSTL 1.2 on another thread. Does that implementation of JSTL require Xalan packaged separately?

Edited by: stevejluke on Aug 16, 2008 7:05 PM
843840
java_everywhere wrote:
thanks balusc, do i search for that on google or ..m kinda new to J2EE stuffs. can u post a url so i can download the required jar.

thanks
[http://google.com/search?q=xpath+site:apache.org].
843840
stevejluke wrote:
BalusC, you had provided a link to Maven and JSTL 1.2 on another thread. Does that implementation of JSTL require Xalan packaged separately?
Not sure, I have never used the JSTL xml taglib.
obinnahenree
Thanks a lot steve and balusc. its working perfecto. Xalan was missing. its working pretty fine now.
wheew, m relieved.

Thanks guys.
1 - 8
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Sep 13 2008
Added on Aug 16 2008
8 comments
318 views