Great. Let me know what you replace request.getFacade()with.
Subir -----Original Message----- From: Venkatesh Sangam [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 25, 2002 12:37 PM To: Tomcat Users List Subject: Re: Request Interceptor hi subir, Thanks for the solution, I got the code working. I was using request.getFacade() to get an instance of httpServletRequest Thanks, Venky ----- Original Message ----- From: Subir Sengupta To: 'Tomcat Users List' Sent: Thursday, April 25, 2002 11:02 AM Subject: RE: Request Interceptor Here's an example of a filter. This will run (after you put in the correct package) as is. It doesn't do anything terribly useful, but it should show you how a filter works. package xx.xx.xx; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class ExampleFilter implements Filter { private FilterConfig config = null; public void init(FilterConfig config) throws ServletException { this.config = config; } public void destroy() { config = null; } public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { System.out.println("Increment your counter here"); chain.doFilter(request, response); System.out.println("Decrement your counter here"); } } In your web.xml add these statements. Put them before any servlet elements. <filter> <filter-name>ExampleFilter</filter-name> <filter-class>xx.xx.xx.ExampleFilter</filter-class> </filter> <filter-mapping> <filter-name>ExampleFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> BTW, what does request.getFacade() do? I'm converting some Tomcat 3.x code to T4 and it looks like that method doesn't exist in T4. Since I didn't write the T3 code in not sure how to replace it. Subir -----Original Message----- From: Venkatesh Sangam [mailto:[EMAIL PROTECTED]] Sent: Wednesday, April 24, 2002 6:03 PM To: [EMAIL PROTECTED] Subject: RE: Request Interceptor Hi Subir, I had the following interceptor class for Tomcat 3.2.2 public class CountRequest extends BaseInterceptor { static int noOfRequests=0; public CountRequest() { super(); } public int preService(Request request, Response response) { try{ HttpServletRequest req =request.getFacade(); if (request.getServletPath().equalsIgnoreCase("/servlet/Read")){ noOfRequests++; System.out.println("/servlet/Read "+noOfRequests); } if (request.getServletPath().equalsIgnoreCase("/servlet/LoadTest")) { Integer load = new Integer(noOfRequests); req.setAttribute("load",load.toString()); System.out.println("/servlet/LoadTest ="+noOfRequests); } } catch (Exception e){System.out.println("Exception is Performance Interceptor");} return 0; } /*postService is invoked right after service() is invoked on the actual servlet*/ public int postService(Request request, Response response) { if (request.getServletPath().equalsIgnoreCase("/examples/servlet/Read")) noOfRequests--; return 0; } } I used to increment noOfRequests in preService and decrement it in postService. But, How do I do the same in Tomcat 4.0 Thanks Venky ----Original Message Follows---- From: Subir Sengupta <[EMAIL PROTECTED]> Reply-To: "Tomcat Users List" <[EMAIL PROTECTED]> To: 'Tomcat Users List' <[EMAIL PROTECTED]> Subject: RE: Request Interceptor Date: Wed, 24 Apr 2002 17:53:42 -0700 T4 doesn't have interceptors. It sounds like you can do what you need to do with a filter. Hope that helps, Subir -----Original Message----- From: Venkatesh Sangam [mailto:[EMAIL PROTECTED]] Sent: Wednesday, April 24, 2002 5:03 PM To: [EMAIL PROTECTED] Subject: Request Interceptor Hi, can any body please tell me where do put my request iterceptor in Tomcat 4 I could easily do this using Tomcat 3.2.2 in server.xml file. I need to intercept request to measure the load in the tomcat server. ie I need to count the number of requests at any point in time.. I already have written the progrom and the interceptor is working fine with Tomcat 3.2.2. But Can any body please tell me how do I do the same using Tomcat 4.0.3 <RequestInterceptor class="CountRequests" /> Thanks Venky _________________________________________________________________ Send and receive Hotmail on your mobile device: http://mobile.msn.com -- To unsubscribe: <mailto:[EMAIL PROTECTED]> For additional commands: <mailto:[EMAIL PROTECTED]> Troubles with the list: <mailto:[EMAIL PROTECTED]> -- To unsubscribe: <mailto:[EMAIL PROTECTED]> For additional commands: <mailto:[EMAIL PROTECTED]> Troubles with the list: <mailto:[EMAIL PROTECTED]> .......Phir Bhi Dil Hai Hindustani Venkatesh Sangam, 1207, E 8th Street, Apt #114, Tempe, AZ, 85281 Ph:480-736-9392 _________________________________________________________________ Chat with friends online, try MSN Messenger: http://messenger.msn.com -- To unsubscribe: <mailto:[EMAIL PROTECTED]> For additional commands: <mailto:[EMAIL PROTECTED]> Troubles with the list: <mailto:[EMAIL PROTECTED]> -- To unsubscribe: <mailto:[EMAIL PROTECTED]> For additional commands: <mailto:[EMAIL PROTECTED]> Troubles with the list: <mailto:[EMAIL PROTECTED]> -- To unsubscribe: <mailto:[EMAIL PROTECTED]> For additional commands: <mailto:[EMAIL PROTECTED]> Troubles with the list: <mailto:[EMAIL PROTECTED]>