• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 648
  • Last Modified:

JSTL xml taglib throwing errors

I have the following JSP pasted below. If I try to compile it is throwing the following exception.
javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/saxpath/SAXPathException
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:268)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause

java.lang.ClassNotFoundException: org.saxpath.SAXPathException
      java.net.URLClassLoader$1.run(Unknown Source)
      java.security.AccessController.doPrivileged(Native Method)
      java.net.URLClassLoader.findClass(Unknown Source)
      java.lang.ClassLoader.loadClass(Unknown Source)
      java.lang.ClassLoader.loadClass(Unknown Source)
      java.lang.Class.getDeclaredMethods0(Native Method)
      java.lang.Class.privateGetDeclaredMethods(Unknown Source)
      java.lang.Class.getDeclaredMethods(Unknown Source)
      java.beans.Introspector$1.run(Unknown Source)
      java.security.AccessController.doPrivileged(Native Method)
      java.beans.Introspector.getPublicDeclaredMethods(Unknown Source)
      java.beans.Introspector.getTargetMethodInfo(Unknown Source)
      java.beans.Introspector.getBeanInfo(Unknown Source)
      java.beans.Introspector.getBeanInfo(Unknown Source)
      org.apache.jasper.compiler.Generator$TagHandlerInfo.<init>(Generator.java:3864)
      org.apache.jasper.compiler.Generator$GenerateVisitor.getTagHandlerInfo(Generator.java:2131)
      org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1619)
      org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1530)
      org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
      org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
      org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2417)
      org.apache.jasper.compiler.Node$Root.accept(Node.java:495)
      org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
      org.apache.jasper.compiler.Generator.generate(Generator.java:3416)
      org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:231)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:347)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
      org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:589)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)




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

<html>  
<body>  
 <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>  
 <x:out     select="$n/author"  />  
  <br>

 ========  
 <br>  
 </x:forEach>
</body>
</html>

Open in new window

0
prsubject
Asked:
prsubject
  • 2
1 Solution
 
rrzCommented:
Please tell what version of Tomcat you are using. Also tellus what version of java you are using.
I think you need to download and install the Xalan jar.  
After you install it, please try the following code.
%@ page contentType="text/html" isELIgnored="true"%>   
<%@ taglib  prefix="c" uri="http://java.sun.com/jstl/core"%> 
<%@ taglib  prefix="x" uri="http://java.sun.com/jstl/xml"%>  

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

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

 <x:forEach select="$doc/books/book">
 <x:out     select="title"  />
  <br>  
 <x:out     select="author"  />  
  <br>

 ========  
 <br>  
 </x:forEach>
</body>
</html>

Open in new window

0
 
rrzCommented:
You can get the Xalan jar   at  
http://www.hightechimpact.com/Apache/xml/xalan-j/   
0

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now