tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: BLOB FROM JSP PAGE
Date Fri, 25 Jan 2002 17:29:58 GMT
On Fri, 25 Jan 2002 Dirk.Dinger@netformfive.de wrote:

> Date: Fri, 25 Jan 2002 17:57:05 +0100
> From: Dirk.Dinger@netformfive.de
> Reply-To: Tomcat Users List <tomcat-user@jakarta.apache.org>
> To: Tomcat Users List <tomcat-user@jakarta.apache.org>
> Subject: Re: BLOB FROM JSP PAGE
>
>
> Hi !
>
> your example has inspired me to try to return an ms-excel document as
> binary-result of a JSP.
> I adopted the code previously provided as follows:
>
> <%@page import="java.io.BufferedInputStream,
> java.io.ObjectOutputStream,java.io.OutputStream,java.io.File"%>
> <%
>   response.setContentType("application/vnd.ms-excel");
>   OutputStream f = response.getOutputStream();
>   File excel= new File("c:/temp/<some_excel>.xls");
>   BufferedInputStream bis = new BufferedInputStream (new
> FileInputStream(excel));
>   int a=0;
>   while ( (a=bis.read()) != -1 )
>   {
>     f.write(a);
>   }
>   bis.close();
> %>
>
> as a result the Exel file is printed out in text format, and the exception
> given below occurs:
>
> What may be the problem here ?
>

The problem is that you are trying to do binary output in a JSP page.
This is not supported.  Use a servlet for dynamically generated binary
output.

> Dirk

Craig


--
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