my dog learned polymorphism*
The moose likes Applets and the fly likes dialog not opening Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "dialog not opening" Watch "dialog not opening" New topic
Author

dialog not opening

john sal
Ranch Hand

Joined: Jul 30, 2010
Posts: 93
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.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
john sal
Ranch Hand

Joined: Jul 30, 2010
Posts: 93
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?
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

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.
john sal
Ranch Hand

Joined: Jul 30, 2010
Posts: 93
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
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18656
    
    8

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.
john sal
Ranch Hand

Joined: Jul 30, 2010
Posts: 93
And how it can be done exactly??
john sal
Ranch Hand

Joined: Jul 30, 2010
Posts: 93
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 ..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: dialog not opening