aspose file tools*
The moose likes Struts and the fly likes Problem with file's name in download dialog Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem with file Watch "Problem with file New topic
Author

Problem with file's name in download dialog

Mike Himstead
Ranch Hand

Joined: Apr 12, 2006
Posts: 178
Hi,

I have a minor problem with sending a file to the client. I have an action that gets an Excel file from a remote database and sends it to the browser using the following code:



The struts-config:


I (have to) use Struts 1.1. Sometimes the browser's download dialog doesn't show the correct filename but the action's name (searchProtocol) instead. Debugging assured that the FileData object is correctly filled and returns the proper name and the header's mime-type is correct as well. The files itselves are always okay/undamaged. It seems as if it somehow depends on the selected file because some files always show the correct names, others never.

Any ideas what can cause this?
[ February 08, 2008: Message edited by: Mike Himstead ]
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

Just a drive-by comment about this line:

AvailableDoesntDoWhatYouThinkItDoes


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Mike Himstead
Ranch Hand

Joined: Apr 12, 2006
Posts: 178
Hi Joe,

thank you for your comment. Is there a mistake or typo in the FAQ? The line


doesn't seem to be correct. I guess what meant is:



Or am I wrong?
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

You are correct. I updated the FAQ.
I looked at the code I'm using to do the same task. It looks very much like yours, but is working correctly. Perhaps some of the file names you are coming up with aren't valid and the browser is falling back on the action name? What names are giving you trouble?
Mike Himstead
Ranch Hand

Joined: Apr 12, 2006
Posts: 178
*slapsforehead*

The filenames contained a slash ("/") which can't be in a filename (at least on Windows platforms). Thank you for your input and have a nice weekend.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with file's name in download dialog