This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

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: 13001
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.
I agree. Here's the link:
subject: Servlet + JDOM
It's not a secret anymore!