File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Close popup after generating a file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Close popup after generating a file" Watch "Close popup after generating a file" New topic
Author

Close popup after generating a file

Julio Ayala
Greenhorn

Joined: Jun 03, 2011
Posts: 15

Hello,

I need to close a popup window after generating a file. The content of the file comes from another application. The popup should be closed after the file is printed, when the streams are closed, but I cannot write anything else in this page because the response has been already commited. Could you give me any ideas?

The process is a little bit confusing, and we are forced to used the other application... I will try to explain the steps clearly:

1. I create the popup where my servlet is going to be executed.
2. The servlet changes the headers and compose the url to call the other application.
3. The servlet reads the results and close the streams. The browser shows the download window.
4. Now the popup is no longer necessary and should be closed, but I can't write in the same page because the response has already been commited.

Any ideas or advices will be appreciated. We are using java5.

Here you have the servlet code:



Thank you in advance
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31075
    
232

Use an AJAX check form the main window to poll for when the download is complete? I'm not clear on why you want to close the child window though. Doesn't it potentially contain a file (depending on user settings.)


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Julio Ayala
Greenhorn

Joined: Jun 03, 2011
Posts: 15

Hello Jeanne,

After saving the file, the popup window is still there, it appears when line 26 is executed. The popup doesn't contain anything. In fact I don't want this window, but I need it to call the servlet and generate the file without changing the main page.

Sorry, but I didn't get the point about the ajax check form, could you give another keyword or something to look for? How could I know the user has executed an action (save, open or cancel)?Or how could I know from the main page that the file has been generated? When the file is generated I can't do forward to another page (the response has been commited) and I don't see the way to include javascript in the popup because everything that I print will be included in the file... Please let me know if you need more details.

Thank you for answering so quickly!

Julio Ayala
Greenhorn

Joined: Jun 03, 2011
Posts: 15

Well...this is not a form, but maybe you were suggesting something like this in the parent window(not with closed, but another event):



The problem is that while the popup is still generating the file, the user could visit another page since de parent window, and this code would never be executed.

Any help will be much appreciated, thank you in advance.
Julio Ayala
Greenhorn

Joined: Jun 03, 2011
Posts: 15

Sorry about this, I forgot it. I have already fixed it.

Actually I'm thinking about using iframes, one for printing the file and another one for closing the popup.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Close popup after generating a file