tumke
asked on
How to invoke a 'save as dialog' in the browsers firefox and safari to store a text string on the client
Ok, I would like to know if the following is possible using a java applet in a webpage:
Is it possible to open an save as dialog and save a txt file on the clients machine with a java applet on a webpage on abrowser?
So The flow would be
1. the java applet gets a text string (via javascript or via the parameters in the html)
2. it opens a save as dialog for the visitor
3. the visitor can browse to a folder on the disk on his own machine and enter a filename (or choose a file to overwrite)
4. then the text string is saved in the file on the disk
Note: I know of the possibilities to trigger a download (and with that a save as dialog) in FF and safari by setting the mime type on the server side of a file but there are some drawbacks to that method that I want to avoid. So I would like to know if the above is possible and if you have some pointers to the solution or examples/articles about it that would be great!.
Is it possible to open an save as dialog and save a txt file on the clients machine with a java applet on a webpage on abrowser?
So The flow would be
1. the java applet gets a text string (via javascript or via the parameters in the html)
2. it opens a save as dialog for the visitor
3. the visitor can browse to a folder on the disk on his own machine and enter a filename (or choose a file to overwrite)
4. then the text string is saved in the file on the disk
Note: I know of the possibilities to trigger a download (and with that a save as dialog) in FF and safari by setting the mime type on the server side of a file but there are some drawbacks to that method that I want to avoid. So I would like to know if the above is possible and if you have some pointers to the solution or examples/articles about it that would be great!.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
>> the visitor can browse to a folder on the disk on his own machine and enter a filename (or choose a file to overwrite)
You can use a JFileChooser for this in a JApplet. Read more on applet-signing here (to get permission for writing to files locally on the client-side): http://www.mindprod.com/jgloss/signedapplets.html
You can use a JFileChooser for this in a JApplet. Read more on applet-signing here (to get permission for writing to files locally on the client-side): http://www.mindprod.com/jgloss/signedapplets.html
http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html