Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-357

Can't use the RequestDispatcher in a separate thread

XMLWordPrintable

    • Icon: Clarification Clarification
    • Resolution: Done
    • Icon: Minor Minor
    • 1.2.0.CR1
    • 1.0.0.Final
    • Servlet
    • None

      Hi,

      I have a job running asynchronously which simulate an HTTP request to retrieve a resource exposed by the container.

      final RequestDispatcher rd = servletContext.getRequestDispatcher(path.charAt(0) == '/' ? path : '/' + path);
      rd.include(new HttpServletRequestWrapper(new MyHttpServletRequestAdapter()), new HttpServletResponseWrapper(myWrappedResponse));

      This will works if I run my code in the same thread as the real HTTP request because undertow checks that this request is actually bound to a ThreadLocal. Also note that everything works fine on tomcat for instance.

      What do you think? I think my approach is legal.

      Bye

              sdouglas1@redhat.com Stuart Douglas (Inactive)
              gdrouet Guillaume Drouet (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: