File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Corrupt Error on ZIP File Download Using Streams in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Corrupt Error on ZIP File Download Using Streams in Java" Watch "Corrupt Error on ZIP File Download Using Streams in Java" New topic
Author

Corrupt Error on ZIP File Download Using Streams in Java

Sankar Nadar
Greenhorn

Joined: Sep 15, 2012
Posts: 3

Hello Friends,
The problem is when i run the below code works fine. But the ZIP file downloaded is corrupt.
Is there any possibilities? any suggestion please.

Actions Done From Side:
1. Checks the downloaded files size.(it same as the orginal file).
2.checks the orginal file(its not corrupted).

Things i noticed :

The below page is the web application in LINUX server and i try to run the same code in windows based application server.
Its works fine in windows and zip file opens properly.
Is there anything related to OS means. How can i resolve that. ?
Is there related to version problem. (MY linux server JDK version is 1.6 and My web application JDK version is 1.5).Means Please help me how to resolve it.?







Please Help me...


Regards,
$ankar
"Dont Knock d DOOR. Jus Brk IT.."
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61187
    
  66

You should not be doing this in a JSP. Please read this article to find out why.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1018
The file will be being corrupted by the JSP printing emitting white space and newlines.
Copying the code into a servlet (it's all java code anyway) and invoking it like that should work
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61187
    
  66

Which is exactly what the article points out. I hope the OP read it.
Sankar Nadar
Greenhorn

Joined: Sep 15, 2012
Posts: 3

Thanks to all... I understood the logic and i start reading all the basic things about the JSP..
The article was nice and easy to understand. Surely i go with the option of servlet for binary data's...

But still i cannt understood one thing.
How my code works in windows based application ?. Bt not in linux..
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61187
    
  66

Different implementations. You were just lucky on Windows.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Corrupt Error on ZIP File Download Using Streams in Java