Copy/pasted from https://developer.jboss.org/message/932789?et=watches.email.thread#932789. Any help would be appreciated...



I'm 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().

 

  1.     @Override  
  2.     public void addCookie(final Cookie cookie) {  
  3.         if (insideInclude) {  
  4.             return;  
  5.         }  
  6.         final ServletCookieAdaptor servletCookieAdaptor = new ServletCookieAdaptor(cookie);  
  7.         if (cookie.getVersion() == 0) {  
  8.             servletCookieAdaptor.setVersion(servletContext.getDeployment().getDeploymentInfo().getDefaultCookieVersion());  
  9.         }  
  10.         exchange.setResponseCookie(servletCookieAdaptor);  
  11.     }  

 

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

 

  1.                 RequestDispatcher dispatcher =  getServletContext().getRequestDispatcher(page);  
  2.                 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.

- See more at: https://developer.jboss.org/message/932789?et=watches.email.thread#932789