Hi,
I have a servlet (code is attached) to convert a xml file to html on server
side. The servlet, XSLServlet.class, is run on Tomcat3.1/WINDOWS 98 at
directory C:\jakarta-tomcat\webapps\ROOT\WEB-INF\classes. The two input
source files, normal.xml and normal.xsl are located at the same directory as
XSLServlet.class is. However, when I involk XSLServlet
(http://localhost/XSLServlet) I got following message:
Error: 500
Location: /servlet/XSLServlet
Internal Servlet Error:
java.io.FileNotFoundException: normal.xsl (The system cannot find the file
specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(FileInputStream.java:64)
at java.io.FileReader.(FileReader.java:38)
at XSLServlet.doPost(XSLServlet.java:25)
at XSLServlet.doGet(XSLServlet.java:19)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:597)
at
org.apache.tomcat.servlets.InvokerServlet.service(InvokerServlet.java:257)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:160)
at
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338)
at java.lang.Thread.run(Thread.java:484)
==============================================================
Could any one tell me why this happens?
Thanks you in advance.
Peter
P.S. Source code:
===============================================================
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import com.lotus.xsl.XSLTInputSource;
import com.lotus.xsl.XSLTResultTarget;
import com.lotus.xsl.XSLProcessor;
import org.xml.sax.SAXException;
public class XSLServlet extends HttpServlet {
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
public void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
doPost(request, response);
}
//Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
PrintWriter out = new PrintWriter (response.getOutputStream());
FileReader xslReader = new FileReader("normal.xsl");
FileReader xmlReader = new FileReader("normal.xml");
response.setContentType("text/html");
try
{
XSLProcessor proc = new XSLProcessor();
//proc.setStylesheetParam("invoiceNum", invoiceNum);
proc.process(new XSLTInputSource(xmlReader),new
XSLTInputSource(xslReader),new XSLTResultTarget(out));
}
catch (SAXException saxE)
{
out.write(saxE.getMessage());
saxE.printStackTrace(out);
}
out.close();
}
//Get Servlet information
public String getServletInfo() {
return "XSLServlet Information";
}
}
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html