• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Opening a zip file from JSP page

 
Ananth Ram
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am creating a zip file and trying to open the zip file from JSP page. The JSP page prompts the user to OPEN/SAVE/CANCEL, but does not open the zip file, however the zip is created in the temporary folder.



Could someone help me in pointing the missing steps.

Thanks in advance for your help.

Ananth Ram
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP are designed to send characters to make a HTML page.

Zip files are NOT character files. Your page is actually sending some starting characters which are NOT in the zip format.

Binary files should be served by a servlet - as has been repeated on this forum many many times before.

Bill
 
Ananth Ram
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,

I am using response.getOutPutStream().

But I am getting the message below



Any thoughts.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64958
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From a JSP or from a Servlet?

As has already been pointed out, using a JSP for this purpose is a phenomenally poor choice.
 
Ananth Ram
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From JSP .

Thanks,
Ananth Ram
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64958
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First step: refactor to a servlet.
 
Ananth Ram
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,

I am planning to move the code on the Struts framework, so I believe the code will be in Action class for the JSP. Please correct me if I am wrong.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64958
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is wrong to be thinking of a JSP at all. JSPs are for generating text like HTML. Not Zip. Not Images. Not anything else binary.
 
Ilari Moilanen
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are talking about Struts 1 there is already a Action class you can use
http://wiki.apache.org/struts/StrutsFileDownload

And as Bear Bibeault said it has nothing to do with JSP since you do not use jsp when downloading files.
 
Ananth Ram
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all,

The link is really useful to implement the download file.

Also on the pointers to use the Servlet instead of JSP.

Same code implemented using Servlet works fine.

Ananth Ram
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic