Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

File Download problem from java  RSS feed

 
sridhar lakka
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
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • 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.
 
Sundaram Karthick
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 ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65825
134
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
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!