dcsimg
Conditional Request Processing
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   ramesh_p
Posted On:   Friday, December 24, 2004 03:31 AM

Hi,

I need to intercept requests processing by the Webserver and I need to add my own filter that is based on some conditions.

Can I do this in java for any of the java or non java webservers or application servers.

Looking for the replies.

Ramesh.

Re: Conditional Request Processing

Posted By:   WarnerJan_Veldhuis  
Posted On:   Friday, December 24, 2004 03:54 AM

You already partially answered your own question: use a ServletFilter: Make a class that implements javax.servlet.Filter. Set it in your web.xml. And that's it.... Use Google for ServletFilter




public class MyServletFilter implements Filter {

public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
//cast request to HttpServletRequest and have fun!!
((HttpServletRequest)request).doSomething();
//and forward the req/resp to the next one, or to the server when done
filterChain.doFilter(request, response);
}
}


In your web.xml:




MyServletFilter
foo.bar.MyServletFilter

someParameter
someValue
sme description




MyServletFilter
/*

About | Sitemap | Contact