Wednesday, March 27, 2013

Re: GWT Sticky Sessions

You don't even need a filter or set the cookie yourself. Just make a call to getSession(true) and it will automagically be set in the Cookies. Typically, you will have some sort of 'initialization' RPC in your module entry point. This is usually a good place to create the session by calling "getLocalThreadRequest().getSession(true). Once your RPC returns, go check your cookies in the browser and you will see the jsessionid there. No need for special filters or any of the rest of it.

On Wednesday, January 23, 2008 4:57:41 AM UTC-7, jas_tat wrote:
Hi All,

I fixed my problem. "Does anyone know how I can pass a plain,
unencoded, jsessionid with all http POST requests which the GWT client
frontend makes?"

In the end I used a servlet filter in order to set a jsessionid as a
cookie for every http response my GWT application made:

import javax.servlet.*;
import javax.servlet.http.*;

import org.apache.log4j.Logger;

public class JsessionidSetter implements Filter
        public static Logger log = Logger.getLogger(JsessionidSetter .class);

        public void init(FilterConfig arg0) throws ServletException

        public void destroy()

        public void doFilter(ServletRequest req, ServletResponse res,
FilterChain chain) throws IOException, ServletException
                HttpServletResponse response = (HttpServletResponse) res;
                HttpSession session = ((HttpServletRequest)req).getSession(true);
                response.addCookie(new Cookie("JSESSIONID", session.getId()));
                chain.doFilter(req, res);

With supporting xml in my web.xml:


Thank you all for your comments anyway!

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment