<div dir="ltr">Thanks for your reply Stuart,<div>i have the handler &quot;HAHandler&quot; 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>  &lt;filters&gt;</div><div>                    &lt;response-header name=&quot;server-header&quot; header-name=&quot;Server&quot; header-value=&quot;WildFly/10&quot;/&gt;</div><div>                    &lt;response-header name=&quot;x-powered-by-header&quot; header-name=&quot;X-Powered-By&quot; header-value=&quot;Undertow/1&quot;/&gt;</div><div>                    &lt;error-page name=&quot;500Handler&quot; path=&quot;${jboss.home.dir}/welcome-content/ErrorPage.html&quot; code=&quot;506&quot;/&gt;</div><div>                    &lt;error-page name=&quot;404Handler&quot; path=&quot;${jboss.home.dir}/welcome-content/ErrorPage.html&quot; code=&quot;404&quot;/&gt;</div><div>                    &lt;filter name=&quot;HAHandler&quot; module=&quot;com.haHandler&quot; class-name=&quot;com.HAHandler&quot;/&gt;</div><div>                &lt;/filters&gt;</div></div></div></div><div><br></div><div><br></div><div>You were correct, by adding some logs,  the sevletInitalHandler hadn&#39;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">&lt;<a href="mailto:sdouglas@redhat.com" target="_blank">sdouglas@redhat.com</a>&gt;</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>
&lt;<a href="mailto:rohan.emmanuel07@gmail.com">rohan.emmanuel07@gmail.com</a>&gt; wrote:<br>
&gt; I am using wildfly 10 and have a filter in my web application which will set<br>
&gt; a attribute in the servlet context.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; public void init(FilterConfig arg0)<br>
&gt;<br>
&gt;     throws ServletException<br>
&gt;<br>
&gt;   {<br>
&gt;<br>
&gt;    ServletContext sc = arg0.getServletContext();<br>
&gt;<br>
&gt;    System.out.println(&quot;setting the servlet context&quot;);<br>
&gt;<br>
&gt;    sc.setAttribute(&quot;ha&quot;,&quot;ha is enabled for this application&quot;);<br>
&gt;<br>
&gt;   }<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; I want to get this attribute in one of my httphandler.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; ServletRequestContext servletreqcontext =<br>
&gt; exchange.getAttachment(<wbr>ServletRequestContext.<wbr>ATTACHMENT_KEY);<br>
&gt;<br>
&gt;     System.out.println(&quot;<wbr>servletreqcontext-=&quot;+<wbr>servletreqcontext);<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; the above code is returing NULL.<br>
&gt;<br>
&gt; Any idea how can i get a handle on the  servletContext in httphandler to get<br>
&gt; this attribute?<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; Regards,<br>
&gt; Rohan Emmanuel<br>
&gt;<br>
</div></div>&gt; ______________________________<wbr>_________________<br>
&gt; undertow-dev mailing list<br>
&gt; <a href="mailto:undertow-dev@lists.jboss.org">undertow-dev@lists.jboss.org</a><br>
&gt; <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>