File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Servlet + JDOM Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet + JDOM" Watch "Servlet + JDOM" New topic

Servlet + JDOM

Nick Lebian

Joined: May 30, 2003
Posts: 9
I want to create an XML-File with a Servlet by using JDOM:
import javax.servlet.http.*;
import javax.servlet.*;
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();
But if I visist the Web-Site, there comes this error advice:
java.lang.NoClassDefFoundError: org/jdom/Element
at parse.(
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
Ranch Hand

Joined: Jan 30, 2003
Posts: 1108
If you're using 1.4 there are included dom & sax apis. Try working with this:

Hope that helps...

"No one appreciates the very special genius of your conversation as the dog does."
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12759
java.lang.NoClassDefFoundError: org/jdom/Element
at parse.(
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.
Consider Paul's rocket mass heater.
subject: Servlet + JDOM
Similar Threads
package org.jdom does not exist
JDOM works normally not with JSP
JDOM parsing and memory
serialization problem with JDOM
DOM (xml) question