You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Lior Shliechkorn <li...@yahoo.com> on 2003/04/14 19:19:40 UTC

[OFF TOPIC] ServletOutputstream Issue

Hi, I'm trying to use POI as a utility to generate a report in excel. The process to generate the report is as following (IIS5 & Tomcat 4.0.5): 1. JSP page with a form2. Servlet to pass the req, res to another servlet (appropriate report)3. Servlet (1. for HTML view and 2. for Excel view) I have no problems except when I try to get the file to be opened or saved on the client side it's trying to open/save the servlet at step 2. It's not prompting to save an xls file or open one, and I'm getting an error of site unavailable and the download fails. Any help would be great with this, since I'm obviously missing something about the outputstream. Again, thanks for taking the time to review my question, Lior


---------------------------------
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more

Re: [OFF TOPIC] ServletOutputstream Issue

Posted by John Turner <to...@johnturner.com>.
On a side note, depending on the complexity of the Excel file you are 
trying to generate, you can do it without any external applications or 
libraries whatsoever.

Excel renders HTML just fine as columns and rows.  Thus, for a simple one 
sheet "Excel file", all you have to do is generate an HTML table with the 
appropriate content type.

John

On Mon, 14 Apr 2003 10:38:26 -0700 (PDT), Lior Shliechkorn 
<li...@yahoo.com> wrote:

> Yes, I have the header in place, and the utility creates a workbook, and 
> then I use the WorkBook.write( outputstream). But for some reason it's 
> not recognizing the excel data, and it's trying to open it up as the 
> servlet name in excel and saying that the file cannot be opened. But when 
> I try to generate the file to disk it works fine.
>
> Erik Price <ep...@ptc.com> wrote:
>
> Lior Shliechkorn wrote:
>> Hi, I'm trying to use POI as a utility to generate a report in excel. 
>> The process to generate the report is as following (IIS5 & Tomcat 4.0.5) 
>> : 1. JSP page with a form2. Servlet to pass the req, res to another 
>> servlet (appropriate report)3. Servlet (1. for HTML view and 2. for 
>> Excel view) I have no problems except when I try to get the file to be 
>> opened or saved on the client side it's trying to open/save the servlet 
>> at step 2. It's not prompting to save an xls file or open one, and I'm 
>> getting an error of site unavailable and the download fails. Any help 
>> would be great with this, since I'm obviously missing something about 
>> the outputstream. Again, thanks for taking the time to review my 
>> question, Lior
>
> How does your servlet serve the Excel file? I am assuming that you are 
> using POI to write directly to the ServletOutputStream, obtained with 
> response.getOutputStream()? If I am not mistaken you may need to set the 
> content-type of the outgoing response:
>
> response.setContentType("application/vnd.ms-excel");
>
>
>
> Erik
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Tax Center - File online, calculators, forms, and more



-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

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


Re: [OFF TOPIC] ServletOutputstream Issue

Posted by Erik Price <ep...@ptc.com>.

Lior Shliechkorn wrote:
> Here is the file...
>  
> Thanks

You have to include it in your email.  (Hopefully it is not too long or 
wider than 80-column lines! :)  The list software does not propagate the 
attachment.

(Eclipse offers autoformatting of source code which can reduce the width 
of lines to less than 80 columns.)


Erik


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


Re: [OFF TOPIC] ServletOutputstream Issue

Posted by Lior Shliechkorn <li...@yahoo.com>.
Here is the file... Thanks

Erik Price <ep...@ptc.com> wrote:

Lior Shliechkorn wrote:
> Yes, I have the header in place, and the utility creates a workbook, and then I use the WorkBook.write( outputstream). But for some reason it's not recognizing the excel data, and it's trying to open it up as the servlet name in excel and saying that the file cannot be opened. But when I try to generate the file to disk it works fine.

I don't mean to suggest the obvious, and this doesn't really sound like 
the source of your problem, but you've confirmed that if you were to 
write this output stream to a File you can open it in Excel with no 
problems? (I'm not really sure what else to suggest, other than perhaps 
posting your servlet code.)


Erik


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



---------------------------------
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more

Re: [OFF TOPIC] ServletOutputstream Issue

Posted by Erik Price <ep...@ptc.com>.

Lior Shliechkorn wrote:
> Yes, I have the header in place, and the utility creates a workbook, and then I use the WorkBook.write( outputstream). But for some reason it's not recognizing the excel data, and it's trying to open it up as the servlet name in excel and saying that the file cannot be opened. But when I try to generate the file to disk it works fine.

I don't mean to suggest the obvious, and this doesn't really sound like 
the source of your problem, but you've confirmed that if you were to 
write this output stream to a File you can open it in Excel with no 
problems?  (I'm not really sure what else to suggest, other than perhaps 
posting your servlet code.)


Erik


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


Re: [OFF TOPIC] ServletOutputstream Issue

Posted by Lior Shliechkorn <li...@yahoo.com>.
Yes, I have the header in place, and the utility creates a workbook, and then I use the WorkBook.write( outputstream). But for some reason it's not recognizing the excel data, and it's trying to open it up as the servlet name in excel and saying that the file cannot be opened. But when I try to generate the file to disk it works fine.

Erik Price <ep...@ptc.com> wrote:

Lior Shliechkorn wrote:
> Hi, I'm trying to use POI as a utility to generate a report in excel. The process to generate the report is as following (IIS5 & Tomcat 4.0.5): 1. JSP page with a form2. Servlet to pass the req, res to another servlet (appropriate report)3. Servlet (1. for HTML view and 2. for Excel view) I have no problems except when I try to get the file to be opened or saved on the client side it's trying to open/save the servlet at step 2. It's not prompting to save an xls file or open one, and I'm getting an error of site unavailable and the download fails. Any help would be great with this, since I'm obviously missing something about the outputstream. Again, thanks for taking the time to review my question, Lior

How does your servlet serve the Excel file? I am assuming that you are 
using POI to write directly to the ServletOutputStream, obtained with 
response.getOutputStream()? If I am not mistaken you may need to set 
the content-type of the outgoing response:

response.setContentType("application/vnd.ms-excel");



Erik


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



---------------------------------
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more

Re: [OFF TOPIC] ServletOutputstream Issue

Posted by Erik Price <ep...@ptc.com>.

Lior Shliechkorn wrote:
> Hi, I'm trying to use POI as a utility to generate a report in excel. The process to generate the report is as following (IIS5 & Tomcat 4.0.5): 1. JSP page with a form2. Servlet to pass the req, res to another servlet (appropriate report)3. Servlet (1. for HTML view and 2. for Excel view) I have no problems except when I try to get the file to be opened or saved on the client side it's trying to open/save the servlet at step 2. It's not prompting to save an xls file or open one, and I'm getting an error of site unavailable and the download fails. Any help would be great with this, since I'm obviously missing something about the outputstream. Again, thanks for taking the time to review my question, Lior

How does your servlet serve the Excel file?  I am assuming that you are 
using POI to write directly to the ServletOutputStream, obtained with 
response.getOutputStream()?  If I am not mistaken you may need to set 
the content-type of the outgoing response:

   response.setContentType("application/vnd.ms-excel");



Erik


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