• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JDOM works normally not with JSP

 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I call this file from command prompt it works fine...
import org.jdom.Element;
import org.jdom.Document;
import org.jdom.output.XMLOutputter;
public class HelloJDOM
{
public static void main(String[] args)
{
//Create a root element for the document
Element root = new Element("Greeting");
root.setText("Hello World");
//Create a new document based on root
Document doc = new Document(root);
try
{
//Output the new document to System.out
XMLOutputter outputter = new XMLOutputter();
outputter.output(doc, System.out);
}
catch(Exception e)
{
System.out.println(e);
}
}
}
ALL the org.jdom.* are found
----------------------------------------
When I use jsp and import the same they are not found...
<%@ page contentType="text/html" %>
<%@page import="java.io.*,org.jdom.*,org.jdom.input.SAXBuilder"%>
<%
SAXBuilder builder =new SAXBuilder("org.apache.xerces.parsers.SAXParser");
Document l_doc=builder.build(new File("c:/message.xml"));
%>
<html>
<body>
<%=l_doc.getRootElement().getChild("message").getText() %>
</body>
</html>
Error Says
org.apache.jasper.JasperException: Unable to compile class for JSP
c:\j2sdkee1.3.1\repository\ucl31-wcsu\web\jdomnew\jdom$jsp.java:4: Package org.jdom not found in import.
import org.jdom.*;
^
c:\j2sdkee1.3.1\repository\ucl31-wcsu\web\jdomnew\jdom$jsp.java:5: Class org.jdom.input.SAXBuilder not found in import.
import org.jdom.input.SAXBuilder;
 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Priya
from command prompt it will work as you might have the CLASSPATH properly set but when you are using JSP then you have to put those JDOM classes (jar files or whatever you have) in the WEBSERVER'S CLASSPATH.
seems you are on Tomcat. you have to add the JDOM classes in Tomcat's classpath and you can do it by adding those jars to - setclasspath.bat (on Windows)...
hope you get somewhere with this pointer.
regards
maulin.
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
btw,
u can find this setclasspath.bat in YOUR_TOMCAT_HOME\bin directory.
this batch file is used by catalina.bat which you might be using to run Tomcat...
regards
maulin
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic