Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2005

Tip: Looking for answers? Try searching our database.

Problem with streamed ZIP file and Windows XP

Thread view: 
Robbie - 09 May 2005 12:36 GMT
I'm having trouble getting Windows XP to open a ZIP file streamed from
a servlet (via Tomcat).

The ZIP contains 1 or more PDFs but when using Windows XP's built-in
ZIP viewer, the ZIP appears empty.  However, WinZip shows the contents
correctly.

I saw this thread about a similar issue:

http://groups.google.co.uk/group/comp.lang.java.programmer/browse_thread/thread/
b7959daace8574c6/703f3c9e17023e89?q=zip+file+windows+xp&rnum=1#703f3c9e17023e89


But in our case filenames do not have semi-colons in the name.

Has anyone else run into this issue and can anyone offer some
suggestions?

Thanks.

Robbie
Chris Uppal - 09 May 2005 13:11 GMT
> The ZIP contains 1 or more PDFs but when using Windows XP's built-in
> ZIP viewer, the ZIP appears empty.  However, WinZip shows the contents
> correctly.
[...]
> But in our case filenames do not have semi-colons in the name.

How about backslashes (\) or other "special" characters (< > * ? : | or ") ?

If you have access to a Unix box, or a Windows port of zipinfo (such as that
included with Cygwin), then using
   zipinfo -v filename
may give you some useful pointer.  As might using the "verify" option in WinZip
(I don't have a copy of WinZip, so I don't know how to invoke that option.  I'm
confident that it has one, though).

   -- chris
Robbie - 09 May 2005 14:04 GMT
Chris -

Thanks for that - we're testing out these options now.

I've read elsewhere that this can be due to XP (SP 2) thinking that the
ZIP file is an attachment and therefore barring access to it.

However, we've tried taking out the "Content-Disposition" header and
are still seeing this behaviour.

Robbie
Robbie - 09 May 2005 15:50 GMT
After a bit of investigating, I think this problem might be due to the
fact that there are spaces in the path name for files contained in the
ZIP file.

We don't actually need the path to be in the ZIP file so this begs the
question: how does one put ZipEntries into a ZipFile *without* the path
information being retained from the original Files' path on the file
system?

Robbie
Chris Uppal - 09 May 2005 17:09 GMT
> After a bit of investigating, I think this problem might be due to the
> fact that there are spaces in the path name for files contained in the
> ZIP file.

Spaces in filenames /shouldn't/ cause problems.  They don't on my system
(XP-pro but without SP2).

> We don't actually need the path to be in the ZIP file so this begs the
> question: how does one put ZipEntries into a ZipFile *without* the path
> information being retained from the original Files' path on the file
> system?

Hmm, how are you creating the zip file ?  With the Java ZIP implementation
(java.util.zip.ZipOutputStream and friends) ?  If so then it should be pretty
obvious -- just set the name to whatever you want (but ensure that it's unique)
when you add the data.

If not then you are using some other tool or library, and I don't know what its
capabilities might be.  I wouldn't be surprised to find that you are using a
utility that can only create ZIP files by adding actual files from the
filesystem, rather than a library that creates ZIP format data in memory out of
other data that is also held in memory.  The first approach seems to be the
most common even for code libraries (and is the only one possible for external
utilities, of course).

What do you mean by the 'path information' ?  If you are building ZIP files
with embedded filenames like
   "C:\this is a test\something.pdf"
then that won't work -- ':' is one of the special characters, and '/' is the
correct separator, not '\' (though Windows does seem to interpret '\' as a
separator in ZIP files).  Anyway you don't want even to /think/ about embedding
/absolute/ paths in a ZIP file.  The filename should be something like:
   "top level/sub dir/something.pdf"
or, merely:
   "something.pdf"
Whatever tool you are using should certainly have some way to control this
aspect of how it works -- if not then ditch it.

Another thing that occurs to me is that if you are building your ZIP data from
real files, then the tool you are using to do it may be adding data that
Windows interprets as file-system permissions (probably copied from the source
PDF files).  The basic permissions are essentially those of DOS/FAT, and one of
the permission flags says that the file is 'hidden', another marks it as being
a 'system' file.  It may be that the entries in the ZIP file have one or other
of these flags set, and that Windows is attempting to honour them (it doesn't
on my system, but then I don't have SP2, and I don't let Windows hide 'hidden'
and 'system' files anyway).  There is also a more elaborate extended (and
optional) set of file permissions that can be set, and which may have a similar
effect, but I don't know anything much about that aspect of the system.

   -- chris
Robbie - 10 May 2005 10:11 GMT
> Spaces in filenames /shouldn't/ cause problems.  They don't on my system
> (XP-pro but without SP2).

I think you're probably right - but we want to remove this possibility.

> Hmm, how are you creating the zip file ?  With the Java ZIP implementation
> (java.util.zip.ZipOutputStream and friends) ?  If so then it should be pretty
> obvious -- just set the name to whatever you want (but ensure that
> it's unique) when you add the data.

Yes, apologies for that, we are using java.util.zip so we will just
change the name of the file being added.

After your suggestion to use zipinfo to compare WinZip files and files
generated by java.util.zip we did identify some differences and we
still have the problem after removing the path I'll post these to see
whether anyone can spot the differences that are preventing Windows XP
from opening the file.

Thanks again for the input.

Robbie


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.