• 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: direct action restoring sessions from cookies problem (Ajax)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: direct action restoring sessions from cookies problem (Ajax)


  • Subject: Re: direct action restoring sessions from cookies problem (Ajax)
  • From: Lachlan Deck <email@hidden>
  • Date: Tue, 26 Jun 2007 05:30:57 +1000

No. That would've been helpful though... Thanks, I'd forgotten about that method.

On 26/06/2007, at 5:16 AM, Chuck Hill wrote:

Did you try calling existingSession()?

On Jun 19, 2007, at 11:10 PM, Lachlan Deck wrote:

Hi there,

I'm seeing a weird thing where DirectAction's getSessionIDForRequest is being called (by the default request- reponse loop stuff) and is returning a valid sesionId but it actually doesn't attach a session to the current context.

Any ideas why? (This is during an Ajax direct action request if that's of any interest).

// here's a work-a-round, but I don't understand why the default mechanism wasn't working.
public DirectAction( WORequest aRequest ) {
super( aRequest );
NSLog.debug.appendln( "<init hasSession>" + context().hasSession () );
String sessionId = this.getSessionIDForRequest( request() );
if ( sessionId != null ) {
NSLog.debug.appendln( "<init restoreSession>" );
Application.application().restoreSessionWithID( sessionId, context() );
}
}


Thanks.

---- Session ----
public Session() {
	super();
	setStoresIDsInURLs( false );
	setStoresIDsInCookies( true );
}
// btw Session extends ERXSession

---- DirecAction ----
public String getSessionIDForRequest(WORequest aRequest) {
String result = super.getSessionIDForRequest( aRequest );
NSLog.debug.appendln( "getSessionIDForRequest:" + result );
NSLog.debug.appendln( new Exception() );
return super.getSessionIDForRequest( aRequest );
}
public WOActionResults ajaxUpdateAction() {
NSLog.debug.appendln( "ajaxUpdateAction hasSession?" + context ().hasSession() );
return pageWithName( AjaxShortlist.class.getName() );
}


---- MyComponent ----
public void appendToResponse( WOResponse aResponse, WOContext aContext ) {
super.appendToResponse( aResponse, aContext );
NSLog.debug.appendln( "hasSession? " + this.hasSession() );
NSLog.debug.appendln( "Cookies: " + aContext.request ().cookieValues() );
}


---- CONSOLE OUTPUT ----
Jun 20 16:00:31 MyApp[55397] (ERXNSLogLog4jBridge.java:44) DEBUG NSLog - getSessionIDForRequest:bGCOTztdVZ0ZyNfmIUc4F0
[2007-06-20 16:00:31 EST] <WorkerThread11> java.lang.Exception
at my.app.DirectAction.getSessionIDForRequest(DirectAction.java:47)
at com.webobjects.appserver.WOAction.initializeRequestSessionIDInContext (WOAction.java:74)
at com.webobjects.appserver.WOAction.<init>(WOAction.java:24)
at com.webobjects.appserver.WODirectAction.<init> (WODirectAction.java:78)
at my.app.DirectAction.<init>(DirectAction.java:15)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at com.webobjects.foundation._NSUtilities.instantiateObject (_NSUtilities.java:575)
at com.webobjects.appserver._private.WOActionRequestHandler.getActionIns tance(WOActionRequestHandler.java:179)
at com.webobjects.appserver._private.WOActionRequestHandler._handleReque st(WOActionRequestHandler.java:229)
at com.webobjects.appserver._private.WOActionRequestHandler.handleReques t(WOActionRequestHandler.java:142)
at er.extensions.ERXDirectActionRequestHandler.handleRequest (ERXDirectActionRequestHandler.java:82)
at com.webobjects.appserver.WOApplication.dispatchRequest (WOApplication.java:1306)
at er.extensions.ERXApplication.dispatchRequest (ERXApplication.java:1041)
at com.webobjects.appserver._private.WOWorkerThread.runOnce (WOWorkerThread.java:173)
at com.webobjects.appserver._private.WOWorkerThread.run (WOWorkerThread.java:254)
at java.lang.Thread.run(Thread.java:613)


=== begin work-around ===
Jun 20 16:00:31 MyApp[55397] (ERXNSLogLog4jBridge.java:44) DEBUG NSLog - <init hasSession>false
Jun 20 16:00:31 MyApp[55397] (ERXNSLogLog4jBridge.java:44) DEBUG NSLog - getSessionIDForRequest:bGCOTztdVZ0ZyNfmIUc4F0
[2007-06-20 16:00:31 EST] <WorkerThread11> java.lang.Exception
at my.app.DirectAction.getSessionIDForRequest(DirectAction.java:47)
at my.app.DirectAction.<init>(DirectAction.java:17)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at com.webobjects.foundation._NSUtilities.instantiateObject (_NSUtilities.java:575)
at com.webobjects.appserver._private.WOActionRequestHandler.getActionIns tance(WOActionRequestHandler.java:179)
at com.webobjects.appserver._private.WOActionRequestHandler._handleReque st(WOActionRequestHandler.java:229)
at com.webobjects.appserver._private.WOActionRequestHandler.handleReques t(WOActionRequestHandler.java:142)
at er.extensions.ERXDirectActionRequestHandler.handleRequest (ERXDirectActionRequestHandler.java:82)
at com.webobjects.appserver.WOApplication.dispatchRequest (WOApplication.java:1306)
at er.extensions.ERXApplication.dispatchRequest (ERXApplication.java:1041)
at com.webobjects.appserver._private.WOWorkerThread.runOnce (WOWorkerThread.java:173)
at com.webobjects.appserver._private.WOWorkerThread.run (WOWorkerThread.java:254)
at java.lang.Thread.run(Thread.java:613)


Jun 20 16:00:31 MyApp[55397] (ERXNSLogLog4jBridge.java:44) DEBUG NSLog - <init restoreSession>
Jun 20 16:00:31 MyApp[55397] (ERXNSLogLog4jBridge.java:38) INFO NSLog - restoreSession trace:
[2007-06-20 16:00:31 EST] <WorkerThread11> java.lang.Exception
at my.app.Application.restoreSessionWithID(Application.java:38)
at my.app.DirectAction.<init>(DirectAction.java:20)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at com.webobjects.foundation._NSUtilities.instantiateObject (_NSUtilities.java:575)
at com.webobjects.appserver._private.WOActionRequestHandler.getActionIns tance(WOActionRequestHandler.java:179)
at com.webobjects.appserver._private.WOActionRequestHandler._handleReque st(WOActionRequestHandler.java:229)
at com.webobjects.appserver._private.WOActionRequestHandler.handleReques t(WOActionRequestHandler.java:142)
at er.extensions.ERXDirectActionRequestHandler.handleRequest (ERXDirectActionRequestHandler.java:82)
at com.webobjects.appserver.WOApplication.dispatchRequest (WOApplication.java:1306)
at er.extensions.ERXApplication.dispatchRequest (ERXApplication.java:1041)
at com.webobjects.appserver._private.WOWorkerThread.runOnce (WOWorkerThread.java:173)
at com.webobjects.appserver._private.WOWorkerThread.run (WOWorkerThread.java:254)
at java.lang.Thread.run(Thread.java:613)
=== end work-around ===
Jun 20 16:00:31 MyApp[55397] (ERXNSLogLog4jBridge.java:44) DEBUG NSLog - ajaxUpdateAction hasSession? false
Jun 20 16:00:31 MyApp[55397] (AjaxShortlist.java:30) DEBUG my.app.MyComponent - hasSession? false
Jun 20 16:00:31 MyApp[55397] (AjaxShortlist.java:31) DEBUG my.app.MyComponent - Cookies: {wosid = ("bGCOTztdVZ0ZyNfmIUc4F0"); woinst = ("-1"); }


These last couple of lines show true with the work-around in place...

with regards,
--

Lachlan Deck



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40global-village.net


This email sent to email@hidden


--

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







with regards, --

Lachlan Deck



_______________________________________________
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: 
 >direct action restoring sessions from cookies problem (Ajax) (From: Lachlan Deck <email@hidden>)
 >Re: direct action restoring sessions from cookies problem (Ajax) (From: Chuck Hill <email@hidden>)

  • Prev by Date: Forcing an object to be faulted?
  • Next by Date: Re: Keep WebObjects, Remove cgi-bin
  • Previous by thread: Re: direct action restoring sessions from cookies problem (Ajax)
  • Next by thread: direct action restoring sessions from cookies problem (Ajax)
  • Index(es):
    • Date
    • Thread