Thanks for the response. 

First off, it is fixed. I will just describe the issue so that it may help 
others. 
Its not a problem with the logic. I was trying-

if (authentication required)
filterConfig.doFilter(...)  //next filter in chain does the actual 
authentication. So pass on the request.
else
request.sendRedirect( request.getServletPath( )) //No authentication reqd. 
display page.

That didn't work because the final sendRedirect( ) caused the filter to be 
invoked again on the same page and thus caused an infinite loop.

To fix, I changed to -
if (authentication required)

filterConfig.doFilter(...)  //next filter in chain does the actual 
authentication.

else {
ServletContext c = filterConfig.getServletContext();
c.getRequestDispatcher(req.getServletPath()).forward(request, response);
}

Forwarding it rather than redirecting solved the problem.

Thanks again.

Av.

----- Original Message ----
From: Tim Lucia <[EMAIL PROTECTED]>
To: Tomcat Users List <users@tomcat.apache.org>
Sent: Monday, May 7, 2007 6:25:34 PM
Subject: RE: How to avoid infinite loop during filter processing?

Sounds like this is a logic problem in your filter; hard to know exactly
what w/o seeing your code & filter definition.  You could change your logic,
possibly by adding a trail of breadcrumbs so the next time through you don't
redirect.  Or, you could consider changing the filter url match pattern to
not include the page(s) to which you are redirecting.

Tim


> -----Original Message-----
> From: webzo [mailto:[EMAIL PROTECTED]
> Sent: Monday, May 07, 2007 8:38 PM
> To: users@tomcat.apache.org
> Subject: How to avoid infinite loop during filter processing?
> 
> Hello,
> I am trying to something fairly simple and have a problem-
> Basically, I use a filter that intercepts access to ALL jsp pages,
> determines whether the user needs to be authenticated. If
> authentication is required, the filter passes it on to the next filter
> (filterchain.doFilter( ) ), else continues on to to originally
> requested page. Problem is, when I try to redirect to the originally
> requested page (because no authentication is required), the redirect is
> also again intercepted by the filter and we go through the same loop
> again- infinite loop. Is there a way to avoid this?
> 
> Thanks.
> 
> Av.
> 
> 
> 
> 
> 
> __________________________________________________________________________
> __________
> Expecting? Get great news right away with email Auto-Check.
> Try the Yahoo! Mail Beta.
> http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






 
____________________________________________________________________________________
Expecting? Get great news right away with email Auto-Check. 
Try the Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html 

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to