• 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

display a "save as" dialog

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is probably very easy to do but I can't find a way to do it.
I have some information displayed on a JSP which I want to save to a simple text file.
On selecting a button I want it bring up the "save as" dialog where the user can decide where to save the file to on their local machine. I can create the file and put data into it in Java, but I can't work out how to bring up the save as dialog from the JSP.
Any help much appreciated! Also any good resources for this sort of thing would also be appreciated.
 
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
There is no standards-compliant method to do this that will work across all browsers. I wouldn't be surprised if there were an IE-only way to do this in that browser, but I wouldn't know. If this is the route that you wish to take, perhaps the HTML/Javascript forum would be a good place to further pursue this.
But I'd say that a better way to do this would be for your button to post a request to a servlet that would set the content type of the response to text and specify it as an 'attachment' (search these forums for this term for exact syntax examples) and then outputs the data in whatever text-only format is approriate.
This should cause the download dialog of the browser to open to allow the user to save the text file to disk.
hth,
bear
 
Ste Lamb
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bear thanks for your response.
I had finally worked it out using the method you suggest - although I'm requesting the info from another JSP. How would I reference a servlet directly?
Thanks for your response though, it doesn't seem to be documented anywhere that this is the way to do it.. altohugh more likely I was searching in the wrong place!
 
I'm so happy! And I wish to make this tiny ad happy too:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic