poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Danny Mui <da...@muibros.com>
Subject Re: weblogic 6.1 writing poi to the response
Date Fri, 05 Sep 2003 17:44:09 GMT
Tomcat needs this too :)

I'm going to add this to the FAQ! I will, I promise.

In Tomcat (well it was Resin for me..), if you click OPEN instead of 
SAVE it fails.  Issuing response.reset() solved this for me so it was a 
hunch.  I found this solution on the FOP mailing lists since it's a 
common enough problem.

Benjamin Simpson wrote:

>Danny
>
>Thanks for the correct tip.  Here are the javadocs, version 1.3 because it
>is Weblogic 6.1 we are talking about, on what response.reset() is supposed
>to do:
>
>"Clears any data that exists in the buffer as well as the status code and
>headers. If the response has been committed, this method throws an
>IllegalStateException.
>Throws:   java.lang.IllegalStateException - if the response has already been
>committed
>See Also:   setBufferSize(int), getBufferSize(), flushBuffer(),
>isCommitted()"
>
>Why weblogic 6.1 needs this, and Tomcat doesn't is a mystery that only the
>weblogic source could shed light upon.
>
>
>BTW,
>
>Flushing the response buffer, see javadocs here
>"http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletResponse
>.html#flushBuffer()" will only push whatever junk was in the the Weblogic
>implementation of HttpServletResponse INTO the xls file that I am pushing
>out to the client.
>
>If you are ever in Michigan or Chicago, I owe you a beer.
>
>Ben
>
>
>
>
>----- Original Message -----
>From: "Danny Mui" <danny@muibros.com>
>To: "POI Users List" <poi-user@jakarta.apache.org>
>Sent: Friday, September 05, 2003 12:52 PM
>Subject: Re: weblogic 6.1 writing poi to the response
>
>
>  
>
>>Also try a call to response.reset() before you do anything.
>>
>>Benjamin Simpson wrote:
>>
>>    
>>
>>>Hello poi users and developers.
>>>
>>>I built web application using poi to assemble spread sheets of data.  I
>>>provide links to jsps which build an HSSFWorkbook and then tell the
>>>      
>>>
>workbook
>  
>
>>>to write via a "wb.write(response.getOutputStream());" call.  There have
>>>been examples on how to do this in the list archives.  I've done this
>>>      
>>>
>before
>  
>
>>>using other contentTypes.  This is truly not a big deal...
>>>
>>>Here is the code I am using.  The plan is to take it out of the jsp AFTER
>>>      
>>>
>it
>  
>
>>>is proven to work:
>>>
>>><%@ page import="org.apache.poi.hssf.usermodel.HSSFWorkbook,
>>>               com.business.poi.WorksheetGenerator"
>>>%>
>>><%
>>>   HSSFWorkbook wb =  new HSSFWorkbook();
>>>   WorksheetGenerator.getInstance().getSheet(wb);
>>>      
>>>
>
>          response.reset();
>
>  
>
>>>   response.setContentType("application/vnd.ms-excel");
>>>   response.setHeader("Content-Disposition","attachment; filename =
>>>business.xls");
>>>   wb.write(response.getOutputStream());
>>>%>
>>>
>>>It works fine on Tomcat 4.1.x.  In fact, it worked the first time.  Which
>>>      
>>>
>is
>  
>
>>>always bad luck.  :(
>>>
>>>I move the war over to Weblogic6.1, not my choice, (NT or Solaris same
>>>results) and the content comes out in a binary format.  This won't go
>>>      
>>>
>over
>  
>
>>>very well with the users who only know how to read spread sheets, not
>>>      
>>>
>binary
>  
>
>>>formats...
>>>
>>>I figured it was a mime issue and stuck an entry into the web.xml:
>>>
>>><mime-mapping>
>>>   <extension>xls</extension>
>>>   <mime-type>application/vnd.ms-excel</mime-type>
>>></mime-mapping>
>>>
>>>ok.  Still doesn't work.  I have been trying different approaches to the
>>>problem to no avail.
>>>
>>>A couple of them included sticking a simple xls file in the application
>>>      
>>>
>and
>  
>
>>>clicking on a link to it through a browser to make sure that it is not a
>>>mime issue.  Great.  I can open excel pre-existing documents through the
>>>browser but not ones that are stuffed into the response's outputStream.
>>>(This opens an ugly and unacceptable workaround of just writing the new
>>>HSSFWorkbooks to the exploded war and response.sendRedirecting to them...
>>>not an option).
>>>
>>>
>>>So here comes the problem statement:
>>>
>>>The above code works on tomcat 4.1.x but not Weblogic 6.1 sp3.
>>>
>>>This is not the first issue that I have run into with Weblogic 6.1 being
>>>funky about writing to the output stream.  What is the deal, any clues?
>>>
>>>Benjamin Simpson
>>>www.javablog.com
>>>
>>>
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: poi-user-help@jakarta.apache.org
>>>
>>>
>>>
>>>      
>>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: poi-user-help@jakarta.apache.org
>>
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: poi-user-help@jakarta.apache.org
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org


Mime
View raw message