Export to GitHub

gwt-dispatch - issue #4

Accessing HTTPSession from ActionHandler implementation


Posted on Jul 27, 2009 by Quick Camel

Hi, first of thanks for the great library ;). I think the only missing piece is the possibility to access the HttpSession (which was used to dispatch the command) from within the ActionHandler. I think this simple patch would allow this. So you could do something like:

servlet.getThreadLocalRequest().getSession();

Beware that this will break the api ;)

Thx, Norman

Attachments

Comment #1

Posted on Jul 28, 2009 by Grumpy Rhino

I would actually lean away from adding it into the ActionHandler interface directly, since there is nothing intrinsic to the API that ties it to requiring a Servlet to be involved. I could have a thread running in the background that executes an action completely on the server side, no servlet request involved at all.

The better alternative is to provide either a global filter that stores the request/response somewhere, accessible via a static method, or possibly to expose the 'getThreadLocalRequest()' value to the public, again via a static method. That way, if a particular action requires it, it can get it, otherwise, it's totally ignored.

Of course, if you're using Guice, you don't need to do any of those things - just inject a Provider into your ActionHandler and call the 'get()' method in your execute method to get the current request object. Handy :)

Comment #2

Posted on Jul 28, 2009 by Quick Camel

You are right, I will try the Provider stuff. Thx for the help

Comment #3

Posted on Oct 21, 2009 by Grumpy Rhino

Closing the issue - the recommendation is to use Provider (if using Guice) or thread-local classes to access the current request.

Status: WontFix

Labels:
Type-Defect Priority-Medium