• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dialog not opening

 
john sal
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 9266
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
john sal
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 9266
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 20983
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And how it can be done exactly??
 
john sal
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic