Forums Register Login

dialog not opening

+Pie Number of slices to send: Send
In action class method i am setting the response as attachment.

response.setHeader("Content-disposition", "attachment; filename=" + fileName);

so when this is called by the jsp page a download dialog is opened to download the attachmetn (which is decided by the browser depending upon the header).

Now the scenario is that i want to call the same code from java applet and i want that a download dialog should be open like the way it is opened when call is made from jsp page to download the attachment whereas currently download dialog is not opened when the call is made from the java file.

How this can be done so that download dialog is opened to save the attachment in the desired location when the call is made from java applet.
+Pie Number of slices to send: Send
You can pop-up dialogs from an applet, though it may be better to put a layer over the applet itself (see this old post, keep in mind things may have changed since I last looked at it).
This question doesn't have anything to do with Struts, so I'll move it to the Applet forum.
+Pie Number of slices to send: Send
Actually when the action class code is called from the JSP page the windows download dialog is opened as the header type is set as an "attachment".


My ques is that is there any way to launch the same windows download dialog instead of creating our own dialog in swing?
+Pie Number of slices to send: Send
I understood your question. My answer is "no", applets don't have the functionality to prompt a user to save a file.
On second thought, you may be able to use the showDocument method of AppletContext to open the URL you wish to download in a new browser window and the browser would use the regular "save as" dialog.
+Pie Number of slices to send: Send
thanks, i will AppletContext and see if it is helpful for my scenario and will let you know in case any clarification is required.

thanks a log
+Pie Number of slices to send: Send
The bottom line is: your applet will have to persuade the browser to send the request, so that it receives the response and pops up that dialog box. So you would use the same code which would cause the browser to display a new HTML page.
+Pie Number of slices to send: Send
And how it can be done exactly??
+Pie Number of slices to send: Send
Hey Joe it worked .. thanks a lot . I used AppletContext and passed the page URL whose response is an attachment. AppletContext tried to open it in a browser and because the response header contains type as an attachment browser's download dialog got opened.

Thanks again ..
He does not suffer fools gladly. But this tiny ad does:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1140 times.
Similar Threads
problem with download dialog box
Enable icon once download request is processed.
Download file HELP?
How do I execute a file download from JSP
file download method
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 02:09:36.