Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > JavaScript > Client side wai...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 35461 of 36380
Post > Topic >>

Client side waiting & timeout

by Simon_21 <thatts@[EMAIL PROTECTED] > May 2, 2008 at 10:44 AM

Hi All,

I have a servlet which is invoked from a jsp page. While the serlvet
is executing, the jsp page is waiting for the servlet to complete.
When the servlet completes, it informs the waiting jsp to redirect to
another page. The waiting jsp has implemented onload which will
redirect to the page informed by the servlet


Server : (tomcat 6.0), Browser - IE 6.0, OS - WinXP



When the servlet takes a long time to return, the page is not
redirected. It seems the browser has given up on the request or timed
out . If the servlet comes back quickly, it works fine. The problem is
seen when the servlet takes a long time to finish.



//waiting jsp code

<html>
<head>
    <title>Please wait......</title>

</head>

<body style='width: 100%;' onload='dynamicRedirect();'>

<br><br>
<div class='indent'><div id='dynamicDisplay'> </div></div>
<script>dynamicDisplayScript( 0, 'please wait' );</script> <br><br>



<%
    out.flush();

    //wait for the serlvet to finish
    String servlet_url = "/servlet/ComputeServlet";
    request.getRequestDispatcher( servlet_url ).include( request,
response );

%>



<SCRIPT language='JAVASCRIPT'>

    function dynamicDisplayScript( x, info )
    {
        var y = 0;
        var tab  = FindElementById( "dynamicDisplay" ) ;
        var display_val = "<h2>"+info;
        var display_end = "</h2>";

        if( Number( x ) == 0 )
        {
            tab.innerHTML = display_val+ "." +display_end;
            y = 1;
        }
        else if( Number( x ) == 1 )
        {
            tab.innerHTML = display_val+ ".." +display_end;
            y = 2;
        }
        else if( Number( x ) == 2 )
        {
            tab.innerHTML = display_val+ "..." +display_end;
            y = 3;
        }
        else if( Number( x ) == 3 )
        {
            tab.innerHTML = display_val+ "...." +display_end;
            y = 4;
        }
        else if( Number( x ) == 4 )
        {
            tab.innerHTML = display_val+ "....." +display_end;
            y = 0;
        }

        var wait = 1000;
        window.setTimeout( "dynamicDisplayScript(" + y + ", '" + info
+ "' )", wait );
    }


    //This is called after the page is loaded when the servet returns
    function dynamicRedirect()
    {
<%
        String url = ( String )request.getAttribute( "RedirectURL");

 %>
        window.location = url;
    }

</SCRIPT>

Appreciate any help

Thanks

_Pete
 




 2 Posts in Topic:
Client side waiting & timeout
Simon_21 <thatts@[EMAI  2008-05-02 10:44:29 
Re: Client side waiting & timeout
Thomas 'PointedEars' Lahn  2008-05-02 21:18:58 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 23:32:29 CDT 2008.