<div dir="ltr">Thanks for your reply Stuart,<div>i have the handler "HAHandler" configured as filter in the undertow subsystem of wildfly.</div><div>I also have eager filter initialization on filter enabled.And the Filter init() method is getting called while application deployment and it had set the servletContext.</div><div><br></div><div><div><br><div><div> <filters></div><div> <response-header name="server-header" header-name="Server" header-value="WildFly/10"/></div><div> <response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/></div><div> <error-page name="500Handler" path="${jboss.home.dir}/welcome-content/ErrorPage.html" code="506"/></div><div> <error-page name="404Handler" path="${jboss.home.dir}/welcome-content/ErrorPage.html" code="404"/></div><div> <filter name="HAHandler" module="com.haHandler" class-name="com.HAHandler"/></div><div> </filters></div></div></div></div><div><br></div><div><br></div><div>You were correct, by adding some logs, the sevletInitalHandler hadn't added the attachment when my handler was called.</div><div>any suggestions how to move my handler in the chain after a specific handler (ServletInitailHandler)?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 16, 2017 at 4:48 AM, Stuart Douglas <span dir="ltr"><<a href="mailto:sdouglas@redhat.com" target="_blank">sdouglas@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Where is your handler running? It sounds like it is running outside<br>
the ServletInitialHandler, which is what sets the attachment key.<br>
<br>
If that is the case you can either move the handler to be run after<br>
the ServletInitialHandler, or save the ServletContext somewhere<br>
static.<br>
<br>
Stuart<br>
<div><div class="h5"><br>
On Wed, Feb 15, 2017 at 9:34 PM, Rohan Emmanuel<br>
<<a href="mailto:rohan.emmanuel07@gmail.com">rohan.emmanuel07@gmail.com</a>> wrote:<br>
> I am using wildfly 10 and have a filter in my web application which will set<br>
> a attribute in the servlet context.<br>
><br>
><br>
><br>
> public void init(FilterConfig arg0)<br>
><br>
> throws ServletException<br>
><br>
> {<br>
><br>
> ServletContext sc = arg0.getServletContext();<br>
><br>
> System.out.println("setting the servlet context");<br>
><br>
> sc.setAttribute("ha","ha is enabled for this application");<br>
><br>
> }<br>
><br>
><br>
><br>
> I want to get this attribute in one of my httphandler.<br>
><br>
><br>
><br>
> ServletRequestContext servletreqcontext =<br>
> exchange.getAttachment(<wbr>ServletRequestContext.<wbr>ATTACHMENT_KEY);<br>
><br>
> System.out.println("<wbr>servletreqcontext-="+<wbr>servletreqcontext);<br>
><br>
><br>
><br>
> the above code is returing NULL.<br>
><br>
> Any idea how can i get a handle on the servletContext in httphandler to get<br>
> this attribute?<br>
><br>
><br>
> --<br>
> Regards,<br>
> Rohan Emmanuel<br>
><br>
</div></div>> ______________________________<wbr>_________________<br>
> undertow-dev mailing list<br>
> <a href="mailto:undertow-dev@lists.jboss.org">undertow-dev@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/undertow-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/undertow-dev</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Regards,<br>Rohan Emmanuel</div></div>
</div>