View Full Version : GWT Session Problem

13 Mar 2009, 5:26 AM
I know this is not the right place for GWT questions, sorry i have to put it here coz i don't know anywhere else that i can get help.

I m doing some Session stuff using Ext GWT, but i even couldn't get a simple thing working. I m trying to get a HashMap from the Session, and save some values to the Map, and retrieve the values later on. What i did is creating RPC, on the server side, the implementation class, i write:

public HashMap getSessionMap(String key) {
if (session.getAttribute(key) == null) {
session.setAttribute(key, new HashMap());

// Return the HashMap
return (HashMap) session.getAttribute(key);

public HttpSession getSession() {
return this.getThreadLocalRequest().getSession();

on the client side, i call this service, get the map, and put values in the map.

But it seems that i get a new map each time i call the service, and there's always only one value in the map. After debugging, i found it's wierd that the HashMap gets created only once(the first time the session attribute is checked), but the map is always empty. I m very confused, the session seems have had the map, but the map can not save any values.

Anyone can help me? please give me some advise about how the Session in GWT should be used, can i save a JavaBean object to the Session?

Any help will be appreciated! Thank you very much!!

Best Regards

13 Mar 2009, 6:30 AM
i sort of solved the problem. this time, i tried to send value to the Servlet and save them in a map instead of getting the HashMap from the Servlet, it works now. I m wondering if this is because the server cannot get the HashMap from Servlet, or any other reasons?

I would also like to get the Map at the client side though, is this a wrong though?


13 Mar 2009, 7:32 AM
still have problem. when save to a map in the session, if i kill the session, the first time is always a failure, in which there's only one record can be retrieved from the map, after the first time, it works well.

i assume that the map or the session is not created properly in the first time, but why this is happening? any idea??

Oscar Porto
31 Aug 2011, 5:47 AM

I'm having the same problem.
Have you already solved it?

thank you