tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rudi Doku" <rudid...@hotmail.com>
Subject Problems Generating PDF from Servlet
Date Wed, 27 Feb 2002 10:24:14 GMT
Hello,

I am trying to develop a servlet that sends a PDF document to a web browser.
I get the following error when i try to display the PDF document:

2002-02-27 01:11:55 StandardContext[/docusoft]: Servlet /docusoft threw 
load() exception
javax.servlet.ServletException: Error instantiating servlet class 
com.docutech.viewer.web.ImageServlet
	at org.apache.catalina.core.StandardWrapper.load(Unknown Source)
	at org.apache.catalina.core.StandardContext.loadOnStartup(Unknown Source)
	at org.apache.catalina.core.StandardContext.start(Unknown Source)
	at org.apache.catalina.core.ContainerBase.start(Unknown Source)
	at org.apache.catalina.core.StandardHost.start(Unknown Source)
	at org.apache.catalina.core.ContainerBase.start(Unknown Source)
	at org.apache.catalina.core.StandardEngine.start(Unknown Source)
	at org.apache.catalina.core.StandardService.start(Unknown Source)
	at org.apache.catalina.core.StandardServer.start(Unknown Source)
	at org.apache.catalina.startup.Catalina.start(Unknown Source)
	at org.apache.catalina.startup.Catalina.execute(Unknown Source)
	at org.apache.catalina.startup.Catalina.process(Unknown Source)
	at java.lang.reflect.Method.invoke(Native Method)
	at org.apache.catalina.startup.Bootstrap.main(Unknown Source)
----- Root Cause -----
java.lang.VerifyError: (class: com/docutech/viewer/web/ImageServlet, method: 
doPost signature: 
(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V) 
Incompatible object argument for function call
	at java.lang.Class.newInstance0(Native Method)
	at java.lang.Class.newInstance(Class.java:237)
	at org.apache.catalina.core.StandardWrapper.load(Unknown Source)
	at org.apache.catalina.core.StandardContext.loadOnStartup(Unknown Source)
	at org.apache.catalina.core.StandardContext.start(Unknown Source)
	at org.apache.catalina.core.ContainerBase.start(Unknown Source)
	at org.apache.catalina.core.StandardHost.start(Unknown Source)
	at org.apache.catalina.core.ContainerBase.start(Unknown Source)
	at org.apache.catalina.core.StandardEngine.start(Unknown Source)
	at org.apache.catalina.core.StandardService.start(Unknown Source)
	at org.apache.catalina.core.StandardServer.start(Unknown Source)
	at org.apache.catalina.startup.Catalina.start(Unknown Source)
	at org.apache.catalina.startup.Catalina.execute(Unknown Source)
	at org.apache.catalina.startup.Catalina.process(Unknown Source)
	at java.lang.reflect.Method.invoke(Native Method)
	at org.apache.catalina.startup.Bootstrap.main(Unknown Source)


My code looks like this

       ServletOutputStream  out = response.getOutputStream ();

        //---------------------------------------------------------------
        // Set the output data's mime type
        //---------------------------------------------------------------

        response.setContentType("application/pdf");  // MIME type for pdf 
doc

        //---------------------------------------------------------------
        // create an input stream from fileURL
        //---------------------------------------------------------------

        String fileURL = "http://localhost/docusoft/jsp/forte-doc.pdf";

        //------------------------------------------------------------
        // Content-disposition header - don't open in browser and
        // set the "Save As..." filename.
        // *There is reportedly a bug in IE4.0 which  ignores this...
        //------------------------------------------------------------
        response.setHeader("Content-disposition",  "attachment; filename=" 
+= "forte-doc.pdf" );

        //-----------------------------------------------------------------
        BufferedInputStream  bis = null;
        BufferedOutputStream bos = null;

        try {
            //URL url = new URL( "http", PROXY_HOST, 
Integer.parseInt(PROXY_PORT), fileURL);
            URL url = new URL(fileURL);

            // Use Buffered Stream for reading/writing.
            bis = new BufferedInputStream(url.openStream());
            bos = new BufferedOutputStream(out);

            byte[] buff = new byte[10000];
            int bytesRead;

            // Simple read/write loop.
            while(-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
                bos.write(buff, 0, bytesRead);
            }

        } catch(final MalformedURLException e) {
            System.out.println ( "MalformedURLException." );
            throw e;
        } catch(final IOException e) {
            System.out.println ( "IOException." );
            throw e;
        } finally {
            if (bis != null)
                bis.close();
            if (bos != null)
                bos.close();
        }


    }



Any help would be most appreciated.

Kind Regards,

Rudi





_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.


--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message