tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefán F. Stefánsson <stef...@snote.decode.is>
Subject File downloading through a servlet problem. This is weird!!!
Date Fri, 22 Dec 2000 16:24:52 GMT
Hello.

I'm experiencing strange things when I download files through a servlet.
The history is that I have access to a file stream in a servlet and I
want the user to be able to download this file.  I do this by sending a
file id as a parameter to the servlet as so:
	
https://localhost/servlet/com.decode.ips.webclient.controller.FileDownlo
adServlet?fileID=111&fileName=somefilename.txt

To begin with I was using some unknown content type to try to force IE
to display the File open/save dialog box.  This was not working and IE
always popped up an error window saying that the file was not available
and I should try later!

After a while of searching the net I found an article about how to
change the default file name for the File open/save dialog box.  That
article suggested the use of the content type application/octet which I
did like so:

	response.setContentType("application/octet; name=" + theFileName
+ "\nContent-Disposition: attachment; filename=" + theFileName +
"\n\n");

This works (well... kindof) except for one thing... and this is the
reason for me posting to the group.  Every time I save a file I get an
some extra lines at the top of the message.  I think there are three
lines.  The first contains nothing but a new line the second contains a
string and the third contains a newline character.  The string in that
second line looks like this:

	Servlet-Engine: Tomcat Web Server/3.2.1 (JSP 1.1; Servlet 2.2;
Java 1.3.0; Windows 2000 5.0 x86; java.vendor=Sun Microsystems Inc.)

One more thing before I ask the obvious question... and this is the
weird part.  When I change the contentType to "text/plain" I get my file
looking exactly like it's supposed to look... I find this very strange!

So... now for my question.  What is this string I'm getting?  Where does
it come from???  How can I get rid of it?  Changing to another content
type is hardly an option since this is the only thing that has worked
for me for IE.  Note: Netscape has always allowed me to save my file
just fine and no hazzle... well.. except that the default file name
doesn't work there... but at least it's not adding those three damn
lines at the top.

I realize this is a browser issue but I don't know where to turn...
e-mail Microsoft for help???  I don't think so!

Any help is greatly appreciated,

kind regards,

	Stefan

--------------------------------------------
Stefan Freyr Stefansson
Software Developer
deCODE Genetics, Inc.
http://www.decode.com

Phone: (+354) 570 2854
GSM:   (+354) 861 1718
Fax:   (+354) 491 3782
 <<Stefan Stefansson.vcf>> 

Mime
View raw message