This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to keep the filename when client opens a streamed file in browser?  RSS feed

 
Henry Leung
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When streaming an excel file to client, how to let client opens it directly in IE without losing the filename I specified?




I am writing a struts webapp. When user clicks a particular button, the html form will be submitted to http://mydomain.com/mywebapp/getreport.do. An excel file will then be streamed to user. User can choose to open it directly in IE, or save it.

This is how I set the http header in the Action class:


It works fine. User will be prompted to open or save the file. The filename myexcelfile.xls is displayed in the prompted dialogue box. If user chooses to save, myexcelfile.xls will be the default filename.

However, if user chooses to open it, the filename myexcelfile.xls will be lost. The excel file will be directly opened in IE. If user clicks File --> Save As, the default filename provided will be getreport.do.

I don't want this to happen, because such a filename (getreport.do) might confuse the user. Does any know a solution?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're doing what you can on the server side. The rest is up to the browser. I've moved this to the HTML forum which as close to a "deal with browser issues" forum as we have.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!