• 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: Ajax Requests and Session Timeouts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Ajax Requests and Session Timeouts


  • Subject: Re: Ajax Requests and Session Timeouts
  • From: Kieran Kelleher <email@hidden>
  • Date: Mon, 22 Nov 2010 14:42:53 -0500

This is copied/pasted directly from my generic Application subclass and demonstrates example logic. Modify it to suit your own needs.....

	/**
	 * Checks Properties for the name of the default page to return upon Session timeout.
	 * If not defined, just returns the super implementation.
	 *
	 * If defined, then checks for Ajax request. If Ajax, returns a page that use javascript to redirect
	 * to a direct action that returns the session timeout page.
	 *
	 * If not Ajax, just returns the session timeout page.
	 *
	 * @property app.sessionTimeoutPageName Name of the page to redirect to when
	 *           this method is called
	 * @see com.webobjects.appserver.WOApplication#handleSessionRestorationErrorInContext(com.webobjects.appserver.WOContext)
	 */
	@Override
	public WOResponse handleSessionRestorationErrorInContext(WOContext context) {
		String page = ERXProperties.stringForKey("app.sessionTimeoutPageName");
		if (page == null) {
			return super.handlePageRestorationErrorInContext(context);
		} else {
			if (AjaxUtils.isAjaxRequest(context.request())) {
				WOResponse response = createResponseInContext(context);
				String defaultUrl = ERXWOContext.directActionUrl(context, WKWODirectAction.class.getSimpleName() + "/sessionExpired", null,
								false);
				response.appendContentString("<script>document.location.href='" + defaultUrl + "';</script>");
				return response;
			} else {
				return pageWithName(page, context).generateResponse();
			}
		}
	}


On Nov 22, 2010, at 2:35 PM, Johnny Miller wrote:

> Hi,
>
> I'm sure this is discussed somewhere but I'm unable to find it.
>
> If a session timeouts between ajax requests how do you handle the response?  I assume it is a combination of WOApplication's handleSessionRestorationErrorInContext and AjaxUtil.isAjaxRequest methods.
>
> Do you just return a javascript method in the response that redirects to a direct action?  I can also see from wocontext that you may be able to triangulate which page the request originated from.
>
> Anyway, any advice would be greatly appreciated!
>
> Johnny Miller
> Kahalawai Media Corp
> http://www.kahalawai.com
>
>
>
> _______________________________________________
> 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

 _______________________________________________
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: 
 >Ajax Requests and Session Timeouts (From: Johnny Miller <email@hidden>)

  • Prev by Date: Re: Ajax Requests and Session Timeouts
  • Next by Date: Re: Ajax Requests and Session Timeouts
  • Previous by thread: Re: Ajax Requests and Session Timeouts
  • Next by thread: Re: Ajax Requests and Session Timeouts
  • Index(es):
    • Date
    • Thread