In a jsp, i have given a link to download a pdf file.
If we set the response content type and attachment etc, the browser pops up a default file download window with open, save and cancel buttons. User can save the respective file to the location and with a different name as per his desire.
Instead of this, i have written my own popup window using awt/swings with open, save, cancel buttons.
In this case, i dont know how to open the respective file, save the content/file coming from response stream to client's machine as it happens in Point No:2
Your point #2 sounds suspicious. Where does this Swing code live - in an applet or Java Web Start application? Otherwise, you can't embed Swing code in a JSP page, because the GUI will be shown on the server, not the client.
When user clicked on the link provided for downloading a pdf file, a html file is called up wherein applet class is called.
I have a java program extending an applet, with an open, save and cancel buttons. I need to open the pdf file when clicked on open button. Similarly, I need to save the pdf file to client machine at the specified/selected location by client.
On click of save button i have included the following.
Frame parent = new Frame(); FileDialog fd = new FileDialog(parent, "Save",FileDialog.SAVE); fd.setDirectory("."); fd.show();
I also have the path of file on which the user clicked for download.
There is no way for you to know whether or not the user has saved the file.
In order to display it, the browser has to download and store the PDF on the hard drive. If the user elects to view it directly in the browser, it is saved to a temporary directory. Either way, they have a copy of it saved to their drive.
Whoever wrote that requirement doesn't understand web programming. It can't be implemented.