• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Handling Session timeout with ajax
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Handling Session timeout with ajax


  • Subject: Re: Handling Session timeout with ajax
  • From: Chuck Hill <email@hidden>
  • Date: Mon, 2 Feb 2009 11:20:48 -0800


On Feb 2, 2009, at 7:02 AM, Robert Tupelo-Schneck wrote:

It doesn't seem to work correctly when I click an AjaxTabbedPanelTab. In that case the tab fills with something that looks like the normal WebObjects session timeout page with a bit of javascript tacked on the end; in fact, if I peek at redirect.contentString(), I get
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>Missing Session Error</title>
...
</html>
document.location.href='/cgi-bin/WebObjects/WOPrefixReg.woa/wo/ 1.0';


Any idea why the <script> etc. is left off in the tab case?

That is not the question. The question is why that HTML is in there. It looks like it is getting generated _before_ AjaxUtils.redirectTo(errorPage) is getting called. Is there anything going on before this in your exception handling method?

Here's my code:

public WOResponse errorPageWith(WOContext aContext, String title, String message) {
if(aContext.hasSession()) {
aContext.session().terminate();
}

And there is your problem! ERXRedirect is returning a re-direct to a component action URL which needs this session. Move this code to ErrorPage in appendToResponse and set the session timeout to a second or two instead of calling terminate() directly.

Thanks, but... what if this is all because of a session timeout in the first place? Even if I remove the the session().terminate() entirely, this still happens.


Now that is an interesting question. You would either have to redirect to a direct action that returns your error page, or create a new session to use in this redirecting code.

Hmmm, that is a bit of a mess.


Chuck



     ErrorPage errorPage = pageWithName(ErrorPage.class,aContext);
     errorPage.title = title;
     errorPage.message = message;

if (AjaxUtils.isAjaxRequest(aContext.request())) {
// Create redirect to return to break out of Ajax
AjaxUtils.redirectTo(errorPage);
WOResponse redirect = errorPage.context().response();
// Generate the error page so that it gets into the page cache, don't do this earlier!
errorPage.generateResponse();
NSLog.out.appendln(redirect.contentString());
return redirect;
}
return errorPage.generateResponse();
}


@Override
public WOResponse handleSessionRestorationErrorInContext(WOContext context) {
super.handleSessionRestorationErrorInContext(context);
return errorPageWith(context,"Session Closed", "Your session has been closed or timed out due to inactivity.");
}




-- Chuck Hill Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects







_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Re: Handling Session timeout with ajax (From: Robert Tupelo-Schneck <email@hidden>)

  • Prev by Date: Re: [Reminder] WebObjects 2008 surveys are still open
  • Next by Date: best practices - .settings and version control
  • Previous by thread: Re: Handling Session timeout with ajax
  • Next by thread: [ANN] JBND 0.9 released
  • Index(es):
    • Date
    • Thread