View Full Version : Doing a wait in a PrintWriter (js)

10 Nov 2011, 2:29 AM
Hi, i'm not sure i'm in the right place to ask that : I need to perform a wait in javascript through a PrintWriter.
Here my problematic : i have a link which redirect the user to an application, this link must provide a SSO.

Here the code once the link is click i call a servlet doing that :

printwriter.println("<script language=\"javascript\"> window.location.href=\"myUrlWithUserIdAndPasswordParametersForSSO\";
window.status = ' ';
var r=confirm(\"Do you want to continue ?\");
if (r) window.location.href=\"MyApplicationUrlAvailableWhenSSOisDone\";
else{ window.open('','_self','');window.opener = top; window.close();}

The problem is, the redirection occured BEFORE the SSO treatment is finish, if the user wait about 5 seconds before clicking "Yes" to the confirmBox, it works... I try to call a setTimeout like that

printwriter.println("<script language=\"javascript\">
function redirectionsso(){
if (r) setTimeout('redirectionsso()',5000)
else { ...}

But it seems it's not going into the redirectionsso() function. Any help will be welcome !

Colin Alworth
11 Nov 2011, 10:55 AM
I'm not exactly sure what you are trying to write, but it looks like this goes on a jsp, not in a GWT application. As far as javascript syntax goes, I'd personally write


setTimeout(redirectionsso, 5000)

If this is a JSP, the printwriter is happening on the server, and is just writing content out to the browser. Once the browser has that content, it will start executing it.

None of this has anything to do with GXT though, you might be better off in a forum for jsps, or for the specific SSO you are trying to use.