[undertow-dev] Sharing session attributes in NonBlocking Handlers and Traditional Servlets

Lightspoke Discussion lsgroup at gmail.com
Mon Mar 10 15:46:20 EDT 2014


Hi Stuart,

I have a regular servlet (the sample... public class HelloWorldServlet
extends HttpServlet) running inside the same web context (in the same war).
 In the HelloWorldServlet I can access the session object.  I ran that
first, but when I run the non-blocking servlet, my reqctx still returns
null.

I'm running Wildfly 8.0.0 final, in case that matters.

So is everything hinging on:


public class ServletInitialHandler implements HttpHandler, ServletDispatcher {
 ...
   public void handleRequest(final HttpServerExchange exchange) throws
IOException, ServletException
   ...

    exchange.putAttachment(ServletRequestContext.ATTACHMENT_KEY,
servletRequestContext);
 ...





On Sun, Mar 9, 2014 at 12:55 PM, Stuart Douglas <sdouglas at redhat.com> wrote:

> This will only be not null after the first servlet handler has run.
> If your handler is executing outside the scope of the servlet deployment
> then you need to store a reference to the ServletContext somewhere (worst
> case = stick it in a static somewhere).
> Stuart
>
>
> Lightspoke Discussion wrote:
>
>> If you are running before the initial handler you need to store a
>> reference to the servlet context or the Deployment somewhere.
>>
>


-- 
--
Matthew Ma
http://www.lightspoke.com
Lightspoke Web Based Database
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20140310/64f3e00c/attachment.html 


More information about the undertow-dev mailing list