Ahh - I reread the original.

Once chain.doFilter(request,response) is called - the response is committed and you are probably seeing IllegalStateExceptions in your logs.

You'll want something like this:

if (someCheckForAuth) {
  sendRedirect( ... )
} else {
  chain.doFilter(request,response)
}



-Tim

Klotz Jr, Dennis wrote:

Thanks for the reply.

Sorry, I guess I didn't explain how I'm applying the filter well enough.

The filter is mapped to my JSP pages.
When a user goes to the URL for the JSP page of interest they get a form
to log in. The action of the form is j_security_check. When the filter
is executed it occurs before j_security_check has been called, because
they have tried to request a JSP page that is mapped to a filter and
j_security_check is a servlet from what I understand. Filters as far as
I know are a layer above servlets and the request goes through the
filter first. That's why I need to, in my filter, call
chain.doFilter(request, response). This makes sure that j_security_check
has done its job. Then I can perform my redirect after j_security_check
has done his job.

So that's why I was using the filter. If you have any other ideas I'd
really appreciate it.


Thanks for your time and help.

-Dennis


-----Original Message-----
From: Tim Funk [mailto:[EMAIL PROTECTED] Sent: Thursday, October 27, 2005 11:48 AM
To: Tomcat Users List
Subject: Re: Trying to use a filter to redirect to a servlet

You can't run a filter against j_security_check

-Tim

Klotz Jr, Dennis wrote:

What I'm trying to do is once a user is authorized on my server, using

FORM based authorization, I want a different servlet (other than what
the user might have originally requested) to be called before any web
page is shown to the user. The servlet helps manage a user's account and
I need to let the servlet know as soon as the user has logged in.


How can I do this?

Here's what I've tried to do writing my own filter.

example of my filter:

public void doFilter(ServletRequest request,ServletResponse

response,FilterChain chain)

{
   // get authorized by j_security_check


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to