return a dynamically created file with Tomcat5

J

Jay Graves

Hello

I am trying to return a file to the user when a certain .jsp or
servlet is requested. For example if the user requests
/webapp/start.jsp I would like to do some computations and based on
certain server setting return the user a file of similar to
user_xxx_yyy.mft (mft == My File Type).

I can get the browser to understand that the response is of a
different content type by either doing.

response.setContentType("application/x-mft");
or
response.setHeader("Content-disposition","attachment;file=test.mft");

But both of those always seem to present the user with a download
dialog with the file name set as "start.jsp". Is there any way to
return a response that sets the default file name to what I specify
(uesr_xxx_yyy.mft)?

Thanks
 
S

sks

Jay Graves said:
Hello

I am trying to return a file to the user when a certain .jsp or
servlet is requested. For example if the user requests
/webapp/start.jsp I would like to do some computations and based on
certain server setting return the user a file of similar to
user_xxx_yyy.mft (mft == My File Type).

I can get the browser to understand that the response is of a
different content type by either doing.

response.setContentType("application/x-mft");
or
response.setHeader("Content-disposition","attachment;file=test.mft");

But both of those always seem to present the user with a download
dialog with the file name set as "start.jsp". Is there any way to
return a response that sets the default file name to what I specify
(uesr_xxx_yyy.mft)?

Try

response.setHeader("ContentType: application/x-mft; name=\"test.mft\"");

or

response.setHeader("Content-disposition","attachment;name=\"test.mft\"");

One should hopefully work. Try with and without the \"s
 
M

Murray

sks said:
Try

response.setHeader("ContentType: application/x-mft; name=\"test.mft\"");

or

response.setHeader("Content-disposition","attachment;name=\"test.mft\"");

One should hopefully work. Try with and without the \"s

response.setHeader("Content-Disposition", "attachment;
filename=\"test.mft\"");

Note *filename*
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top