struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Parfitt" <>
Subject Setting browser download dialogue box captions and suggesting file names
Date Mon, 01 Dec 2003 10:42:11 GMT
My application has form containing a table with hyperlinks in one column.

When a user clicks on one, a request is made to the server passing in the ID of the chosen
file (Microsoft Word) to be downloaded.

The file is then downloaded to the user's browser (Internet Explorer - V5) but I cannot find
how to influence the caption/contents of the various dialogue boxes, even though I tried a
method suggested in a posting to this list dated 2001.

The essential logic in the file is the following :-

	OutputStream os = null;

	HttpSession session = request.getSession();
	ComponentManager cm = (ComponentManager)session.getAttribute(CitadelKeys.COMPONENT_MANAGER);
	IDownloadBD IDownloadBD = cm.getDownloadBD(session);

	BigInteger rgmtMfst = new BigInteger(request.getParameter("fileID"));		

	response.setHeader("Content-Disposition", "attachment; filename=Portfolio_Document.doc");
	response.addHeader("Content-Description", "Portfolio Report Download");

	String AcceptEncoding = request.getHeader("Accept-Encoding");

	if ((AcceptEncoding != null) && (AcceptEncoding.indexOf("gzip") != -1))
		os = new GZIPOutputStream(response.getOutputStream());
		if (response.containsHeader("Content-Encoding")) { response.setHeader("Content-Encoding",
"gzip"); }
		else { response.addHeader("Content-Encoding", "gzip"); }
	else { os = response.getOutputStream(); }

	//download the file via the BD...
	IDownloadBD.downloadFile(os, rgmtMfst);

	ActionMessages webClientMessages = new ActionMessages();
	webClientMessages.add("portfolio", new ActionMessage(""));
	saveMessages(request, webClientMessages);


But the target filename suggested by the Content-Disposition header gets replaced by download.doc
somewhere and the Content-Description header does nothing (as far as I can tell).

I have tried response.setContentType("application/x-download"); and the only difference is
that the suggested filename changes to "download" instead of being "download.doc"

On the Content-Disposition header, in addition to the one shown above, I have tried others

    "attachment; filename=\"C:\\Portfolio_Document.doc\";"
    "attachment; filename=\"Portfolio_Document.doc\";"
    "attachment; filename=\"Portfolio_Document.doc\""

and none of them have any effect either.

Searching the web reveals Internet Explorer and Opera as known culprits for bad compliance
with the relevant Internet protocols, so has anyone found a way to :-
    suggest a target filename
    create meaningful dialogue captions
When the Client browser is Internet Explorer V5 ?

Is there some "helpful" facility in IE5 that I need to turn off (or on) ?
Is my code inherently wrong ?

All solutions gratefully received ...


Mike Parfitt 
JMH Demica Ltd 
Crowne House,
56-58 Southwark Street 
SE1 1UN 

Direct:      +44 (0) 20 7450 2539 
Switchboard: +44 (0) 20 7450 2500 
Fax:         +44 (0) 20 7407 5825 
This document should only be read by those persons to whom it is 
addressed and is not intended to be relied upon by any person 
without subsequent written confirmation of its contents. JMH 
Demica accepts no liability for the consequences for any person 
acting, or refraining from acting, on such information prior to 
the receipt by those persons of subsequent written confirmation 
(by letter or fax). If you have received this email message in 
error, please notify the sender immediately by telephone. Please 
also delete the message from your computer. Any form of 
reproduction, dissemination, copying, disclosure, modification, 
distribution and/or publication of this email message is 
prohibited. The contents of this email message do not 
necessarily reflect the opinions of JMH Demica. Citadel is the 
registered trademark of JMH Demica. Copyright JMH Demica all 
rights reserved. 


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message