tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randy Layman <randy.lay...@aswethink.com>
Subject RE: BLOB FROM JSP PAGE
Date Fri, 25 Jan 2002 16:17:38 GMT

	Your problem stems from (A) you can't call response.getOutputStream
after you call response.getWriter and (B) all JSPs call response.getWriter
before they start executing your code.  Move the code to a servlet and you
will be fine.

	Randy


> -----Original Message-----
> From: Dirk.Dinger@netformfive.de [mailto:Dirk.Dinger@netformfive.de]
> Sent: Friday, January 25, 2002 11:57 AM
> To: Tomcat Users List
> 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 ?
> 
> Dirk
> 
> ------------------------------------------
> 
> java.lang.IllegalStateException: OutputStream is already 
> being used for
> this request
>            at
> org.apache.tomcat.facade.HttpServletResponseFacade.getWriter(H
ttpServletResponseFacade.java:175)
> 
>            at
> org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.
> java:166)
>            at
> org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterI
mpl.java:158)
>            at
> org.apache.jasper.runtime.JspWriterImpl.flush(JspWriterImpl.java:205)
>            at _0002fexcel_0002ejspexcel_jsp_6._jspService
> (_0002fexcel_0002ejspexcel_jsp_6.java:84)
>            at
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
>            at 
> javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>            at
> org.apache.jasper.servlet.JspServlet$JspCountedServlet.service
> (JspServlet.java:130)
> 
>            at 
> javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>            at
> org.apache.jasper.servlet.JspServlet$JspServletWrapper.service
> (JspServlet.java:282)
> 
>            at
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet
> .java:429)
>            at
> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
>            at 
> javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>            at
> org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper
> .java:405)
>            at org.apache.tomcat.core.Handler.service(Handler.java:287)
>            at
> org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
>            at
> org.apache.tomcat.core.ContextManager.internalService(ContextM
anager.java:812)
> 
>            at
> org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)
>            at
> org.apache.tomcat.service.http.HttpConnectionHandler.processCo
> nnection(HttpConnectionHandler.java:213)
> 
>            at
> org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoin
> t.java:416)
>            at
> org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPo
> ol.java:501)
>            at java.lang.Thread.run(Thread.java:484)
> 
> 
> 
> 
> 
> --
> 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>
> 

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