File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Specify the dynamic name for setting a file for downloading?

 
Varun Narang
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,
These days I am working on a project, and I am facing some problem in it. The thing is that I need to display some results as a result of the database query, and I need to provide a link so that user can download the file by clicking on it. I want to dynamically assign the file-name (as default) and the file I am retriving is from database it self. Can anyone help me with the solution of how to do this.
Thanks & Regards,
Varun Narang.
 
Manish Hatwalne
Ranch Hand
Posts: 2591
Android Firefox Browser Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a "Content-Disposition" header that allows you to send filename that you can allow your users to download.

It should be something like this -
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);

where fileName is the dynamic filename that you want.
Do remember to set MIME type accordingly for the file.

HTH,
- Manish
 
Varun Narang
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mr. Hatwalne,
That was a great help.
Thanks a lot once again.

In the mean time, I was playing with Initialization parameters, I found something really strange. It's about case-sensitivity of param-names. The case is as follows:
If in web.xml file of my application, while specifying <init-param> tag for Servlet, I specify string for <param-name> in INITCAP, I am not able to retrive the value of <param-value> when I use getServletConfig().getInitParameter("Initcap-word").
Is this a bug, or contradicting the conventions. Can anyone tell me about that?
Thanks in Advance,
Regards,
Varun Narang.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic