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
    chain.doFilter(request,response) 
    // post filtering operation 
    
    // construct redirect url 
    
    StringBuffer url = new StringBuffer(100);
 
     // http or https 
     url.append(request.getScheme());    
     url.append("://");
 
     // the host name or IP address
     url.append(request.getRemoteHost());
    
     // add the port number to handle any firewall or NAT issues
     
    url.append(request.getRemotePort()); 
    
      // add the path to the servlet
     url.append(SERVLET_PATH);
     
     // add the original url so we can be redirected correctly after login
     // the servlet will not perform a redirect if it already has some user's
     // authorized credentials
     // the default behavior of j_security_check to forward to the correct 
     // page after the user is authorized is fine
 
     url.append("?");
     
     url.append("requrl=");
     
     url.append(request.getRequestURL()); 
 
    url.trimToSize();
 
    // encode the URL
    String encURL = response.encodeRedirectURL(url.toString());
  
    response.sendRedirect(encURL);
 
 
}
 
I have a filter that's applied to my jsp pages. This filter is applied right 
before a j_security_check is called. So I want it to perform the 
j_security_check so I know I have to call the method
 
chain.doFilter(request,response) so that j_security_check will be executed from 
my filter. 
 
After the user is authorized I want to redirect to a servlet to perform some 
processing then have the servlet redirect the user to the correct page. I 
create the URL to the servlet correctly and I have a parameter in the query 
string that has the URL I want to go to once my servlet has finished.
 
The issue is that I perform the j_security_check by calling chain.doFilter and 
then afterwards I make the method call 

response.sendRedirect(response.encodeURL(URL_TO_MY_SERVLET));
 
I never get redirected to my servlet.
 
If I type the URL to my servlet my servlet does what it's supposed to.
 
 
Any help is appreciated.
 
-Dennis 

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

Reply via email to