You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Pancham <pa...@gmail.com> on 2009/10/11 07:15:27 UTC

Re: Prevent request filter invocation when struts action tag is invoked

This does NOT work. When an action is invoked using "s:action" in JSP, even
if dispatcher is set as below, the request filter is being invoked.
Is there any work-around?

Thanks.



Musachy Barroso wrote:
> 
> Use the "dispatcher" element in the "filter-mapping" element in web.xml,
> like:
> 
>  <filter-mapping>
>         <filter-name>MyFilter</filter-name>
>         <url-pattern>/*</url-pattern>
>         <dispatcher>REQUEST</dispatcher>
>     </filter-mapping>
> 
> On Fri, Oct 9, 2009 at 10:16 AM, Pancham <pa...@gmail.com> wrote:
>>
>> I have a request filter that needs to be executed only once during
>> processing
>> of a request. Unfortunately, whenever another action is included within
>> the
>> same request using "action" tag, my request filter is invoked.
>> How can I prevent invocation of request filter when an action is included
>> using action tag? Or, is there any way to find out in the filter that it
>> is
>> being invoked as a result of action invocation within the same request.
>>
>> Thanks.
>> --
>> View this message in context:
>> http://www.nabble.com/Prevent-request-filter-invocation-when-struts-action-tag-is-invoked-tp25824829p25824829.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> 
> 
> -- 
> "Hey you! Would you help me to carry the stone?" Pink Floyd
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Prevent-request-filter-invocation-when-struts-action-tag-is-invoked-tp25824829p25840798.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Prevent request filter invocation when struts action tag is invoked

Posted by Pancham <pa...@gmail.com>.
Here is my request filter code:
public class MyFilter implements Filter {
    private FilterConfig filterConfig = null;
 
    public void init(FilterConfig filterConfig)
            throws ServletException {
        this.filterConfig = filterConfig;
    }

    public void destroy() {
        this.filterConfig = null;
    }

    public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain)
            throws IOException, ServletException {
        if (filterConfig == null)
            return;
        // MY CODE HERE
    }


and here is the mapping in web.xml:
<filter-mapping>
        <filter-name>MyFilter</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
    </filter-mapping>

While processing an request, if I include an action using struts action tag
("s:action"), this filter is invoked again during the same request. So, if I
have 2 "s:action" tags in my JSP, the filter is being called 3 times - once
for request and two times for "s:action".

Any ideas on how this could be addressed?


Musachy Barroso wrote:
> 
> What REQUEST FILTER is this you are talking about?
> 
> On Sat, Oct 10, 2009 at 10:15 PM, Pancham <pa...@gmail.com> wrote:
>> request filter
> 
> 
> 
> -- 
> "Hey you! Would you help me to carry the stone?" Pink Floyd
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Prevent-request-filter-invocation-when-struts-action-tag-is-invoked-tp25824829p26045181.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Prevent request filter invocation when struts action tag is invoked

Posted by Musachy Barroso <mu...@gmail.com>.
What REQUEST FILTER is this you are talking about?

On Sat, Oct 10, 2009 at 10:15 PM, Pancham <pa...@gmail.com> wrote:
> request filter



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org