• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in creating zip file on weblogic server

 
Tushar Mundada
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When i run following code on a tomcat server on local machine it rus fine & gives a correct zip file but when I run this on weblogic server then it gives error as

error:[c:\Documents & settings\mt1\local settings\temporary internet files\myzipfile[1].zip]": start of central directory not found. Zip file corrupt.
Possible error: Zip file error


Can anybody please help me in this?



 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

That will probably already solve your problem. When read(byte[]) returns 0 that doesn't mean all data is read. It means there's currently no data available. -1 is the only value that indicates that you're done reading.

Also, you can remove this line:
reader.read(buffer) will re-fill the existing array. It's possible (likely even) that one or more reads do not overwrite all old data, but you know that all values from 0 to bytesRead (exclusive) are filled with new data, and this is exactly the portion you then write. In other words, all you're doing is create another array where no new array is necessary.
 
Tushar Mundada
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did above changes. its still not working. It seems there is problem with the header of the zip file. Can anybody help to resolve exactly?
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If this is a JSP, make sure that absolutely no output is sent to the response before you use your code. That includes line breaks outside of JSP directives / tags. Even enters between your import directives will already be sent to the response.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!