aspose file tools*
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet + JDOM" Watch "Servlet + JDOM" New topic
Author

Servlet + JDOM

Nick Lebian
Greenhorn

Joined: May 30, 2003
Posts: 9
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

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
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet + JDOM