• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Downloadinf a file from server

 
madupathi arun
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

i am having folowing problem

I need to take the user specific directory and pass that to servlet file

I am calling document.execCommand('SaveAs','1','filename.xml'); on the click of download button


but I was unable to pass that file directory using this
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you writing this DHTML out? Can you show us your servlet code?
 
madupathi arun
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

my requirement is to show saveas dialogue when i clickm on download button
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15354
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What a browser does when a file of a certain type is sent to it by the server depends on the Content-Type HTTP header that's in the response.

If Content-Type is set to "text/xml", then the browser will probably display it as an XML file.

If the Content-Type is set to something that the browser doesn't recognise, then it will offer the user a Save As dialog box. If you set the Content-Type to "application/octet-stream" (which means: this is generic data), then it will most likely show you the Save As dialog box.

So what you need to do is set the Content-Type HTTP header of the response before you send back the file from your servlet.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic