Search code examples
javasessionservletsthread-local

request.getSession() vs getThreadLocalRequest().getSession()


What is the difference between

request.getSession() 

and

getThreadLocalRequest().getSession()

The application I am maintaining appears to use the first for straight Servletsand the second for anything implemented via GWT-RPC which itself extends servlet.


Solution

  • They both return the same thing. GWT simply stores the request sent in from the servlet into a thread local so that you don't need to pass it around in every method call and still have a separate request for each invocation.