1 Reply Latest reply on Jun 4, 2015 5:46 AM by jaikiran pai

    Undertow doesn't write cookie to response

    John Sipher Newbie

      I'm (still) trying to migrate an application from JBoss 7,.2.0.Final to WildFly 8.2.0.Final, and I find that some cookies are not written to the servlet response. I've tracked it down to io.undertow.servlet.spec.HttpServletResponseImpl.addCookie().


          public void addCookie(final Cookie cookie) {
              if (insideInclude) {
              final ServletCookieAdaptor servletCookieAdaptor = new ServletCookieAdaptor(cookie);
              if (cookie.getVersion() == 0) {


      Apparently the insideCookie flag has been set to true at the point we're calling HttpServletResponse.addCookie(), so WildFly/Undertow just quietly throws it away and leaves me scratching my head trying to figure out what went wrong.


      When I search back up the call stack I see that our servlet is including a JSP page in its response like this


                      RequestDispatcher dispatcher =  getServletContext().getRequestDispatcher(page);
                      dispatcher.include(state.getRequest(), state.getResponse());


      So, it makes sense that insideInclude is true, since the code that's trying to set the cookie is being called from inside RequestDispatcher.include(), but I don't understand why WildFly/Undertow just arbitrarily throws it away.