aspose file tools*
The moose likes JSP and the fly likes Opening a zip file from JSP page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Opening a zip file from JSP page" Watch "Opening a zip file from JSP page" New topic
Author

Opening a zip file from JSP page

Ananth Ram
Ranch Hand

Joined: Jan 18, 2001
Posts: 99
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

Joined: Mar 22, 2000
Posts: 12806
    
    5
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

Joined: Jan 18, 2001
Posts: 99
Thanks,

I am using response.getOutPutStream().

But I am getting the message below



Any thoughts.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61436
    
  67

From a JSP or from a Servlet?

As has already been pointed out, using a JSP for this purpose is a phenomenally poor choice.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ananth Ram
Ranch Hand

Joined: Jan 18, 2001
Posts: 99
From JSP .

Thanks,
Ananth Ram
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61436
    
  67

First step: refactor to a servlet.
Ananth Ram
Ranch Hand

Joined: Jan 18, 2001
Posts: 99
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

Joined: Jan 10, 2002
Posts: 61436
    
  67

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

Joined: Apr 15, 2008
Posts: 198
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

Joined: Jan 18, 2001
Posts: 99
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Opening a zip file from JSP page