Hi, I am reading Jason Hunter's Java Servlet Programming book. on Page 92 (chapter 4, example 4-10) the servlet use String contentType = getServletContext().getMimeType(req.getPathTranslated()); seems doesn't work for me. I am using Netscape Enterprise Server 3.5.1(on solaris) JSDK 2.0 http://exon/servlet/Lily.ViewFile2/index.html it translated the file to the right path, but give me the following error message: java.lang.ClassNotFoundException at sun.servlet.ServletLoader.loadClass(ServletLoader.java:123) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336) at Lily.ViewFile2.doGet(ViewFile2.java:32) * at javax.servlet.http.HttpServlet.service(HttpServlet.java:252) at javax.servlet.http.HttpServlet.service(HttpServlet.java:330) at sun.servlet.netscape.NSRunner.run(NSRunner.java:144) at netscape.server.applet.ServerApplet.handleRequest(ServerApplet.java:69) at netscape.server.applet.HttpApplet.handleRequest(HttpApplet.java:680) the file getPathTranslated is /export/WWW/suitespot/docs/banner.gifEND ================== copied from Jason's book ============= package Lily; import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; import com.oreilly.servlet.ServletUtils; public class ViewFile2 extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { // use a ServletOutputStream because we may pass binaryinformation ServletOutputStream out = res.getOutputStream(); // get the file to view String file = req.getPathTranslated(); out.println("the file getPathTranslated is " + file + "END"); //no file, noting to view if ( file == null ) { out.println("No file to view"); return; } //get and set the type of the file String contentType = getServletContext().getMimeType(file); res.setContentType(contentType); //return the file try { ServletUtils.returnFile(file, out); } catch (FileNotFoundException e) { out.println ("File not found"); } catch (IOException e) { out.println ("Problem sending file: " + e.getMessage()); } } } ___________________________________________________________________________ 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
