• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

File Download problem from java  RSS feed

 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks in advance.
In our application we are using following code to save the file in XML format.

response.setContentType ("text/xml");
String filename=".xml";
response.setHeader ("Content-Disposition","attachment;filename="+filename);

With this it is opening a dialogue box prompting for name of the file,
but there is .xml[2],.xml[1].
Which is incorrect,actually I need there should be .xml direct, that is empty file name by default.
Please help me.

Regards,
Sree
 
Rancher
Posts: 42975
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason it's putting the number behind the filename is probably bcause ".xml" exists already. I wouldn't use a filename that starts with ".", though. If accepted, the file will be invisible on Unix.
 
sridhar lakka
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for the reply.
I am not giving the file name as '.' it is the extension suffix. like '.xml'.
And I am sure there is no such file existed for duplicate.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I put this in a jsp and when i run it in tomcat 5.5 and invoke the jsp using IE 7. It works fine
<%
response.setContentType ("text/xml");
String filename="me.xml";
response.setHeader ("Content-Disposition","attachment;filename="+filename);
response.getWriter().write("<kfdj>jjjdfjd<dkfjdk>");
response.getWriter().flush();
response.getWriter().close();

%>
Hope this helps
[ August 08, 2007: Message edited by: Sundaram Karthick ]
 
Author and ninkuma
Marshal
Posts: 66806
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course, Sundaram Karthick is not advocating doing anything like this in a JSP, he's just providing that as a sample test. (right?)
 
Sundaram Karthick
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, Bear Bibeault. My intention of adding this piece of code was to just say it was working in my environment, as you said doing this type of activity in jsp is not that bright idea
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!