Session/user management approach for multiple servlets in GWT/GAE app

108 views
Skip to first unread message

Alex Dobjanschi

unread,
Jul 8, 2011, 6:54:12 AM7/8/11
to google-a...@googlegroups.com
Hi,
I've been unsuccessful in sharing a piece of data (Account) between multiple servlets (doing custom user management, not using UserService).
I'm developing a GWT/GAE app, where multiple client services get implemented by different servlets. What's the best/good approach for this?

Upon login/create account, the serializable Account is stored in one attribute of getThreadLocalRequest().getSession(). I can successfully read that data using the same servlet (AccountServlet), but any other servlet can't ... anything I'm doing wrong? I can also work with any pattern, if supplied :)

Thanks,
Alex

Stephen Johnson

unread,
Jul 8, 2011, 1:03:29 PM7/8/11
to google-a...@googlegroups.com
I'm assuming this is on production not dev? Do you have  <sessions-enabled>true</sessions-enabledin your appengine-web.xml? Are you seeing the sessions persisted to the datastore in _ah_Session?

Stephen

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine/-/YKmDudoBfwQJ.
To post to this group, send email to google-a...@googlegroups.com.
To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.

Alex Dobjanschi

unread,
Jul 13, 2011, 7:30:51 PM7/13/11
to google-a...@googlegroups.com
Sorry for the late response, but I got it working somehow (actually I understood how, but I'm not happy with the current implementation).

Basically what I have is an AccountServlet that performs the login (checks email/passwd combo etc). After validation, the Account is stored in servlet session. The original question was, how to approach user management for multiple servlets?

In a secondary servlet, I need the authentified user. Even more, I define a RemoteService that gets implemented in both the servlet and a delegate (much more useful for junit testing). How should I efficiently work with the Account in the implementation?

interface ISearchService {
 Object doSearch (String query);
}


SearchServlet {
 ISearchService impl = new SearchServiceImpl (); // parameterless constructor (DI).
 public Object doSearch (String query) {
   return impl.doSearch (query);
 }
}

Assume the SearchServiceImpl requires the authentified account. I can successfully fetch it in Servlet. How do I serve it to the impl?
Thanks
Reply all
Reply to author
Forward
0 new messages