ok, I see, but the
.henric
| www.abelbaker.com | [EMAIL PROTECTED] |
----- Original Message -----
From: Geoff Soutter <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, October 07, 1999 7:23 AM
Subject: Re: downloading a file via servlet
here's an extract from the code I use. check the comments, you should be
able to figure it out.
// Set the filename
// IE4 will use content disposition filename only if it doesn't
recognise the
// mime type by "sniffing"! Setting mime type explicitly to "crap/crap"
doesnt work
// this especially affects HTML .... obviously!
// IE5 will use content disposition filename, but for HTML only
"attachment" seems
// to work - if "inline" it still gets the filename from TITLE tag. Both
attachment
// and inline work for zip files...
// NS4 uses the filename but ignores the type (attachment or inline),
thus you can use
// the crap/crap mime type trick to fool it into showing a save as box
String lType = "inline";
// if the user is trying to say this is an attachment
if (iUseAttachmentDisposition)
{
lType = "attachment";
// this will fool NS4 into giving the user the save as box!
// and won't really do anything for IE5. Also, IE4 ignores it...
usually...
iContentType = "application/x-max-unknown";
}
// strip any pathname
String lFileName = iContentName;
int lLastSlashPos = lFileName.lastIndexOf( '/' );
if (lLastSlashPos != -1)
lFileName = lFileName.substring( lLastSlashPos + 1 );
// NOTE: quotes around filename will confuse <= ie4sp1 (fixed in sp2)
iResponse.setHeader( HttpHeaders.sCONTENT_DISPOSITION, lType + ";
filename=\"" + lFileName + "\"");
-----Original Message-----
From: Henric Larsson <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Thursday, 7 October 1999 14:59
Subject: downloading a file via servlet
>Hi,
>
>I have written a servlet that let's a user download files located in a
>database, the problem is that the user clicks on a link that looks like
>this:
>
><a
>href="/servlet/FileServlet?command=get_file&file_id=1234">LargeFile.doc</a>
>
>now when the save file dialog box pops up, it want to save the file as
>FileServlet.zip. I want to modify this so the filedialog box gets the files
>real name, that is stored in the database.
>
>I this possible, are there any headers to set or what should I do?
>
>thank you
>
>
>.henric
>
>| www.abelbaker.com | [EMAIL PROTECTED] |
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html