AFAI, You can't use PrintWriter to output binary data.  use 
getOutputStream().  Print writer will attempt to handle
encoding which should totally mangle your binary (xls) data.

-Andy

anders wrote:

>I have the similar problem, but my code is in my servlet instead of a jsp
>file.
>
>I tried to insert the line " out.clearBuffer(); " but I got a compile error.
>    cannot resolve symbol
>    symbol  : variable out
>
>So, I added this line "PrintWriter out = response.getWriter(); "
>Then I get this error
>    cannot resolve symbol
>    symbol  : method clearBuffer  ()
>
>My questions are
>1)  "What is out?"
>2)  Did I miss a jar file in my classpath?
>
>Thank
>
>anders
>
>
>"ibo" <[EMAIL PROTECTED]> wrote in message
>[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>  
>
>>i solved the problem by inserting out.clearBuffer() :P
>>i realized that JSP Engine (ie. resin) inserts
>>a new line character due to the presence of page
>>directive at the top. i noticed this when i tried
>>downloading plain text file.
>>
>>my code now appears :
>>out.clearBuffer();
>>response.setContentType("application/vnd.ms-excel");
>>response.setHeader("Content-Disposition",
>>"attachment; filename=\"" + fileName + ".xls" + "\"");
>>ServletOutputStream stream =
>>response.getOutputStream();
>>ts.writeExcelData(stream);
>>stream.close();
>>
>>thx for the inputs guys :). sorry for my jsp but it
>>was just my own mini-project to generate my timesheet
>>:> (a 2-page jsp).
>>
>>--- "Riley, Cameron" <[EMAIL PROTECTED]> wrote:
>>    
>>
>>>ibo,
>>>
>>>  Try setting the content length of the stream you
>>>are writing to the output
>>>stream in the response object.
>>>
>>>
>>>
>>>      
>>>
>>response.setContentLength(bytearayoutputstream.size());
>>    
>>
>>>  In my case, I write a List of workbooks to a
>>>ZipOutputStream and return it
>>>as a ByteArrayOutputStream.
>>>
>>>
>>>Cameron Riley
>>>
>>>
>>>--
>>>To unsubscribe, e-mail:
>>><mailto:[EMAIL PROTECTED]>
>>>For additional commands, e-mail:
>>><mailto:[EMAIL PROTECTED]>
>>>
>>>      
>>>
>>__________________________________________________
>>Do You Yahoo!?
>>Sign up for SBC Yahoo! Dial - First Month Free
>>http://sbc.yahoo.com
>>    
>>
>
>
>
>
>
>--
>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