visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Languages :: Java :: Setting File Name for the Downloaded Content


By: madanmohan India  Date: 15/06/2005 08:10:38  English  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 English  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 English  Type : Comment
and ?
By: VGR Date: 04/07/2005 13:23:59 English  Type : Comment
you may also find useful to send along the content-length header
By: VGR Date: 21/07/2005 11:52:59 English  Type : Comment
was that helpful enough ?
By: VGR Date: 21/07/2005 12:16:49 English  Type : Comment
?
By: VGR Date: 04/10/2005 09:12:16 English  Type : Comment
Allo Madanmohan ? Please close this abandoned Question.
By: OpConsole Date: 09/10/2005 09:55:25 English  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

EContact
browser fav
page generated in 108.025790 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page