?
Solved

Window closed but request still running

Posted on 2006-04-17
12
Medium Priority
?
329 Views
Last Modified: 2010-04-01
We have a web application running on WebLogic 8.1. On the client browser, a child pop-up window accepts inputs from the user. When the user clicks the Submit button, the application will take a while to process the request, then show the results on the same pop-up window. The problem is this: sometimes the user may click the close button (the X button on the top right hand corner of the window) before the processing is finished. In this case, I would guess that the processing would be prematurely terminated by this action. But it seems that I am wrong. The processing still keeps going on despite the fact that the window is already closed. What could be the reason and how to solve the problem?

Also, when the link for the pop-up window is clicked again (to open the pop-up window). The pop-up window will show, but its dynamic contents will only appear after the processing of the previous request is finished.

For your information, we are using Struts/Spring/Hibernate as well for the web application.
0
Comment
Question by:yongsing
  • 6
  • 2
9 Comments
 
LVL 2

Accepted Solution

by:
borislavmarkov earned 252 total points
ID: 16468285
This is normal behaviour, request stays running. Your server cannot know if you closed the browser by pressing "X" because browser does not send anything when closing.
I suggest 2 approaches:

On your HTML page put unload event that notifies the server:

<script>
function terminate(){
 location.html = "http://localhost:8080/myapp/terminate.do";
}
</script>
<body onunload="javascript:terminate()">
....
</body>

I am not sure how you will implement that.

Second approach is to modify your servlet to return response immediately and start another thread.
Page will refresh permanently : you may use second frame with

<META HTTP-EQUIV=Refresh CONTENT="10; URL=http://....">
which will refer to another servlet which will check if your thread has finished.

Believe me you do not have many options to workaround this!


0
 
LVL 11

Expert Comment

by:fargo
ID: 16468761
other way is to show a "wait page.." so that the end user knows that the process is still going on...
0
 
LVL 11

Assisted Solution

by:fargo
fargo earned 248 total points
ID: 16468776
my last post doesn't give u any option of informing the server about client trying to close the browser. Personally i think, u should definitely give end user some kind of indication that the process is still ongoing...

Don't handle this situation in a complex way and keep it simple.

following link will show u how to display a waiting message
http://www.experts-exchange.com/Web/Web_Languages/JSP/Q_21791432.html
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Author Comment

by:yongsing
ID: 16474680
Thanks guys for your information. Actually my pop-up window already displays a wait message (with javascript) when the Submit button is clicked.

The pop-up window (let's call it the child window) is actually launched from a link on the parent browser window. We only want one instance of the child window, so if the child window is already opened, clicking the link on the parent's page will simply bring the child window to focus, instead of creating a new one. The javascript to do this is like this on the parent's page:

var childWindow = null;

function openChildWindow() {
  var url = '<%=request.getContextPath()%>/Child.do?event=prepare';
  if (childWindow) childWindow.close();
  childWindow = window.open(url, 'child', 'scrollbars=no,menubar=no,height=600,width=800,resizable=no,toolbar=no,location=no,status=no');
  childWindow.moveTo(screen.availWidth/2-400,screen.availHeight/2-300);
  childWindow.focus();
}

Now suppose that the child window is opened, and we fill in the inputs and click the Submit button. While processing, we click the Close button. Then we click the link on the parent window's page to launch the child window again. The child window is blank and won't display it's contents (generated from JSP) until the processing of the previous request is complete. So it seems to me that the child window is actually running the request on a single thread. When the previous request processing is not complete, the child window's current contents won't be displayed. I think if we allow multiple instance of the child window, this problem would not occur.

To further my investigations, when I click the Close button on the child window while still processing, I click the link on the parent's page on another PC. This time the child window on the other PC displays its contents without delay.

So my conclusion is that the same window instance can only run one request at a time. If it is re-open after being closed, it will wait for its previous request processing to finish first. Am I right?
0
 
LVL 11

Expert Comment

by:fargo
ID: 16475867
So my conclusion is that the same window instance can only run one request at a time. If it is re-open after being closed, it will wait for its previous request processing to finish first. Am I right?#

>> NO. If you reopen the child window which was closed before. The present state will have no idea of what was done in the last. I don't think it is depending upon the previous state of req/response (Untill unless u have some code to have that handling)
0
 
LVL 11

Expert Comment

by:fargo
ID: 16475904
u may use window.onunload to prompt an alert to the end-user.
0
 
LVL 9

Author Comment

by:yongsing
ID: 16476548
>> NO. If you reopen the child window which was closed before. The present state will have no idea of what was done in the last. I don't think it is depending upon the previous state of req/response (Untill unless u have some code to have that handling)

In that case, why is the child window showing blank until the previous processing is complete?
0
 
LVL 11

Expert Comment

by:fargo
ID: 16476560
r u sure u don't have any special handling in /Child.do
0
 
LVL 11

Expert Comment

by:fargo
ID: 16762021
there was no response from the asker. I would object for refund. Points should be awarded.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If anyone asked you to network diagram of the internet, it was drawn in the form of a fluffy cloud which further became known as cloud computing. Popularly cloud computing is defined as workloads that run over the internet in a commercial provider’s…
LinkedIn blogging is great for networking, building up an audience, and expanding your influence as well. However, if you want to achieve these results, you need to work really hard to make your post worth liking and sharing. Here are 4 tips that ca…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Screencast - Getting to Know the Pipeline
Suggested Courses

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question