My writer writes binaries to output stream.

Stmt is an Oracle BFILE, response is HttpServletResponse, length doesn't
matter.

        InputStream in = null ;
        BufferedInputStream bis = null ;
        ServletOutputStream writer = null ;
     
        try
        {
            stmt.openFile() ;
            in = stmt.getBinaryStream() ;
            bis = new BufferedInputStream(in) ;
            int length ;
            byte[] buf = new byte[512] ;
            writer = response.getOutputStream() ;
            response.setContentType("application/pdf") ;
            while ((length=bis.read(buf))!= -1)
            {
                writer.write(buf) ;
            }
        }
        finally
        {
            if (writer != null)
                writer.close() ;
            if (in != null)
                in.close() ;
            if (bis != null)
                bis.close() ;
            if (stmt != null)
                stmt.closeFile() ;
        }
    }

In my Action class, I return null.

It works perfectly if Adobe Acrobat Reader is installed.


Regards,
 
 
PQ
 
"This Guy Thinks He Knows Everything"
"This Guy Thinks He Knows What He Is Doing"

-----Original Message-----
From: Marcus Biel [mailto:[EMAIL PROTECTED]] 
Sent: January 16, 2003 7:37 AM
To: [EMAIL PROTECTED]
Subject: Re: Action without forward ?

> I don't understand why you cannot directly use the PDF-generator servlet,
by
> adding a dedicated mapping in your web.xml.
It needs to go through the request processor, to check if the user is
logged in
or not. 

> perform() method in any action MAY return an ActionForward, but CAN return
> null if it has build the response for the client browser. This is commonly
> used for PDF or Excel generation, where they're is no need for a JSP.

It writes the binary value(pdf) into the response.getOutputStream,
with content-Type "application/pdf" und with content-length set.
But in the browser nothing can be seen, even though the pdf that gets
created correctly,
and the browser is loading the pdf-plugin.


Any ideas ?

marcus



[EMAIL PROTECTED] schrieb:
> 
> perform() method in any action MAY return an ActionForward, but CAN return
> null if it has build the response for the client browser. This is commonly
> used for PDF or Excel generation, where they're is no need for a JSP.
> 
> I don't understand why you cannot directly use the PDF-generator servlet,
by
> adding a dedicated mapping in your web.xml.
> 
> Nico.
> 
> > Hi, I am using Struts 1.02 and got the following Problem:
> > I need to create a JSP where u can select to create a pdf or excel file.
> >
> > The problem is, I didn't programm the Action to create the file, a
> > colleague did.
> > So I need some way to call his Servlet. I tried to map directly to it,
> > that did not work. So I wrote an Action that called a method to create
> > this pdf / excel file,
> > depending on the parameters given.
> >
> > The problem is, that after this method there is no forward anymore, as
> > the control is given to the servlet
> > to create the file, and thats it. But the
> > public ActionForward perform(
> > ActionMapping mapping,
> > ActionForm form,
> > HttpServletRequest request,
> > HttpServletResponse response)
> > {
> >
> > needs some forward.
> > For the moment I wrote "return null" but imho thats no prober solution.
> >
> > Maybe you got an idea.
> >
> >
> > thanks,
> >
> > marcus
> 
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

Reply via email to