Reputation: 1204
I have this line in the constructor of my RemoteServiceServlet
userID = getThreadLocalRequest().getRemoteUser();
but its throwing NullPointerException because getThreadLocalRequest returns null.
My understanding was that RemoteServiceServlet inherits from HttpServlet and hence should have the HttpReuest object already !! Do I need to set anything before calling getThreadLocalRequest() in case of GWT?
Upvotes: 0
Views: 614
Reputation: 22451
The problem could be that you are trying to use that method inside the constructor of a servlet. A new servlet instance is not created for each request. Servlet instances are reused across requests. Try calling getThreadLocalRequest() inside a service method instead.
Upvotes: 2