aspose file tools*
The moose likes Servlets and the fly likes Specify the filename of a dynamically generated image? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Specify the filename of a dynamically generated image?" Watch "Specify the filename of a dynamically generated image?" New topic
Author

Specify the filename of a dynamically generated image?

Philippe Desrosiers
Ranch Hand

Joined: Mar 29, 2006
Posts: 138
I have a servlet that dynamically generates images. Everything is working fine, except when the client application (say, a browser) attempts to save the image, the filename is something like imgserver.do.png. I would like to be able to control the filename of the generated image, as visible to the client. I know there is a way to do this, I think bby setting a response header, but I can't remember how. Can anyone help?

thanks,
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61764
    
  67

Search this forum and perhaps google for the term "content-disposition".


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
pawank gupta
Ranch Hand

Joined: Jun 07, 2006
Posts: 34
use response.setHeader("contenttyep","application/gif");
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by pawank gupta:
use response.setHeader("contenttyep","application/gif");


The original poster asked about setting the file's name, not it's type.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Philippe Desrosiers
Ranch Hand

Joined: Mar 29, 2006
Posts: 138
Originally posted by Bear Bibeault:
Search this forum and perhaps google for the term "content-disposition".


This was a while ago, but setting the "content-disposition" header did indeed work.

thanks,
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
use the content-disposition in which you can specify the name of the file.


Rahul Bhattacharjee
LinkedIn - Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Specify the filename of a dynamically generated image?