• Post Reply Bookmark Topic Watch Topic
  • New Topic

File download problem  RSS feed

 
Ranch Hand
Posts: 186
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear friends,

I have a link in a JSP. On clicking it an HTML file gets downloaded. When i click the link, the file download dialog box appears with the Open,Save,Cancel options.

When i click the Open button, the HTML file gets opened in the same window. I want to avoid this one.
How to make the file open in a new window, when the user clicks Open button from the file download dialog box? I'm using IE 7.0.

Kindly provide your help.
Regards,
Vijay
 
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the target attribute for either the anchor tag or the form tag.
Moving to HTML/Javascript
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vijay,

Add this line to the the HTML page to be opened in new window.

response.addHeader("Content-disposition","attachment; filename = myFilename.xls");

Put this code in a jsp scriplet.

Hope this is of some help for you.
 
Vijay Chandran
Ranch Hand
Posts: 186
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for your reply. But the solution provided by you didn't work. Perhaps i didn't understand it properly.

Could anyone please explain a little bit more on what exactly to do?
Can i solve the problem by writing it in Action class?


Regards,
Vijay
[ March 20, 2008: Message edited by: vijaychandran rajagopalan ]
 
Author and ninkuma
Marshal
Posts: 66348
155
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ben gave you the solution to the problem.
 
Mehul Wani
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vijay,

It seems your's is an Struts application. As you are using action class,
add this line in your action class,
response.addHeader("Content-disposition","attachment; filename = myFilename.xls");

before in_mapping.findForward();
Note that this will work only if you are forwarding the request through action class and not directly to the html page.
Feel free to get more details if needed.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!