• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

File Download problem from java

 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Eliminate 95% of the weeds in your lawn by mowing 3 inches or higher. Then plant tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic