Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet + JDOM

 
Nick Lebian
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
I want to create an XML-File with a Servlet by using JDOM:
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
import java.util.*;
import org.xml.sax.*;
import org.jdom.Attribute;
import org.jdom.Comment;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;
public class parse extends HttpServlet
{
private Element root;
private Document doc;

public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException, IOException
{

root=new Element("test");
doc=new Document(root);
PrintWriter out = response.getWriter();
out.println("testtext");
}
}
But if I visist the Web-Site, there comes this error advice:
java.lang.NoClassDefFoundError: org/jdom/Element
at parse.(parse.java:17)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
...
When I compile the programm, there comes noch error advices. Can anyone help me?
Bye, Nick
 
John Dunn
slicker
Ranch Hand
Posts: 1108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're using 1.4 there are included dom & sax apis. Try working with this:

Hope that helps...
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13056
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.lang.NoClassDefFoundError: org/jdom/Element
at parse.(parse.java:17)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

That just indicates the servlet can't see the jar file that has the JDOM classes. I believe the Tomcat developer docs that come with the standard download talks about where jar files must be placed.
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic