• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

File download problem

 
Ranch Hand
Posts: 186
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ben gave you the solution to the problem.
 
Mehul Wani
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic