Languages :: Java :: Setting File Name for the Downloaded Content |
|||
| By: madanmohan |
Date: 15/06/2005 08:10:38 |
Points: 20 | Status: Answered Quality : Excellent |
|
Hi I am working on Mobile related applications using java. I have witten a code which is used for download process on the mobile. The content is getting downloaded properly on to the Mobile Hand Set. But the problem is the File Name is the name of the jsp i am using. Suppose my code is in file called "Download.jsp", after successful download of the content it is showing Download.jsp as the file name. So is there any way that the file name can be changed to the one we wish by setting any headers. I have tried it by using the folowing but it is working IE not on Mobile Hand Set. response.setHeader("Cont-Disposition","attachment; filename=" + filename +";"); Can any one help me to solve this. Thanks, Madan |
|||
| By: VGR | Date: 15/06/2005 21:10:02 | Type : Answer |
|
| Hello 8-) I must say that I encountered the very same problem when I was generating PDF files on-the-fly. I see different options : 1) try this kind of simple setting : header('Content-Type: application/pdf'); header('Content-Disposition: inline; filename=contacts.pdf'); 2) try this more (over-) complicated one : Header("Content-Type: application/pdf; name=$locname"); Header("Content-Transfer-Encoding: base64"); Header("Content-Description: $locname"); Header("Content-Disposition: inline; filename=$locname"); Where you'll see I tried all the possible ways to set the "file name" : via the "name=" in content-type, via "content-description" and via the "filename" in content-disposition 3) try to save your file to disk, then send it to the browser/hend-held device using the Java equivalent of a passthru() or file() command in PHP 4) perhaps the first thing to do is to fix your "Cont-Disposition" to read "Content-Disposition" ;-) |
|||
| By: VGR | Date: 23/06/2005 16:01:38 | Type : Comment |
|
| and ? | |||
| By: VGR | Date: 04/07/2005 13:23:59 | Type : Comment |
|
| you may also find useful to send along the content-length header | |||
| By: VGR | Date: 21/07/2005 11:52:59 | Type : Comment |
|
| was that helpful enough ? | |||
| By: VGR | Date: 21/07/2005 12:16:49 | Type : Comment |
|
| ? | |||
| By: VGR | Date: 04/10/2005 09:12:16 | Type : Comment |
|
| Allo Madanmohan ? Please close this abandoned Question. | |||
| By: OpConsole | Date: 09/10/2005 09:55:25 | Type : Comment |
|
| Hello. This is the last reminder before forced closure of the Question. Suggested choice : Accept first VGR answer. You may Accept or Split the answer by clicking on the relevant button of the relevant comment ;-) Regards |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








