• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Servlet + JDOM

 
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
 
slicker
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...
 
Author and all-around good cowpoke
Posts: 13078
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
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!