This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes (servlet) downloading a dynamically generated file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "(servlet) downloading a dynamically generated file" Watch "(servlet) downloading a dynamically generated file" New topic
Author

(servlet) downloading a dynamically generated file

Javoso Torso
Ranch Hand

Joined: Aug 15, 2003
Posts: 88
Hello there,

I am pretty tired of search the net...
So I post the Q here.

I am trying to download a dynamically generated file. It is not a real file I have in the server but an "Apache POI HSSFWorkbook", which can be downloading by the client as an excel sheet (or HorribleSpreadSheetFormat .

I found a lot of aproaches for "real files". How is it with "objects" in cache (like a HSSFWorkbook).

Thanks for any help,
javo


I hate 'trial and error'<br />and I am doing it all the time
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
For dynamic files, you could simply write a rountine that writes the dynamic content to the ServletOutputStream when the rountine is invoked. The content can be generated within that rountine as well, no matter a *real* Excel file, or CSV files.

Nick


SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
Javoso Torso
Ranch Hand

Joined: Aug 15, 2003
Posts: 88
Thanks Nick,

I also tryed that aproach. And it partly works!

Better explained:

I am using JSF.
The download method is in a action-methode which I call from one page. I have to present the "download-Mask" and (after the download or the cancel) return to the same page.
So far so good and working well. I can open the downloaded file and it is all ok.
BUT
My problem is when I try to use another "action method" in that page (after the download)
it comes again the "download-Mask" !!
even if that has nothing to do with this other "action method".

So: something not closed? I try many other ways with no result...

CODE:

faces-config:




downloadMethod:
(as written above I already used other ways like: the write method from HSSFWorkbook, or other dispositions, etc.)




page:




Any ideas?
Thanks!
javo
[ December 17, 2004: Message edited by: Javoso Torso ]
Javoso Torso
Ranch Hand

Joined: Aug 15, 2003
Posts: 88
 
jQuery in Action, 2nd edition
 
subject: (servlet) downloading a dynamically generated file
 
Similar Threads
apache poi excel workbook won't open after download
excel
Facing Problem with String replaceAll method
Printing HTML file in java
Apache POI :Export to xls(Coloured Cell) not working in MS Excel