Search code examples
gwtparametersgwt-rpchttpsession

HttpSession changes inbetween calls to Servlet and GWT RPC Servlet (RemoteServiceServlet)


I have a GWT application which I would like to run from within a Joomla layout. The concept seems to work fine and the application loads up correctly. Joomla uses an iFrame to achieve this and just sends off the url which will kick start the GWT application.

The issue I am having is that I require certain information from Joomla, which I pass as parameters in the url. Since a GWT application starts up from an HTML page, giving me no way to access those parameters, I am instead firing off a request to a Servlet, the idea being that I can grab those parameters, save it in the session and then serve the GWT applications HTML page.

The concept works fine. I grab the parameters, put them into a map, that map goes into a basic bean and I store the bean as a session attribute with the code:

request.getSession().setAttribute("sessionBean", sessionBean);

The Servlet then serves out the GWT HTML page, which in turn loads up the application, and the first thing it does is fire off an RPC call. The issue I am having is in my RemoteServiceServlet handling that call, I attempt to fetch my SessionBean with the following code:

SessionBean sessionBean = (SessionBean) this.getThreadLocalRequest().getSession().getAttribute("sessionBean");

I get null, and looking closer realise that it has in fact created a new session. I know this by comparing the id's of the two sessions. Any subsequent further RPC calls all have access to the last session but the one I stored my SessionBean in is gone!

It is all one deployed war file, cookies are enabled, and it acts this way both in development and production mode.

I figure I am probably misunderstanding the way sessions are handled! Any ideas as to why the GWT RPC call creates a new session? Or maybe if I am going about this completely wrong, how to get these needed parameters into a session?

Any help or ideas will be greatly appreciated!

Thanks in advance!

Xandel


Solution

  • In gwt you can get the url-parameters by:

    Window.Location.getQueryString()