Profile filter ver. 1.7

This is a Java servlet filter (as per Servlet API 2.3). This filter lets you create a profile for your web pages. So filter will collect execution (response) times for the all requests. And you will use ProfileServlet or custom JSP taglib for checking this statistics in the real time.

How to use it:

a) download profflt.jar and save it in WEB-INF/lib

b) describe this filter in web.xml.
 


<filter>
  <filter-name>profileFilter</filter-name>
  <filter-class>com.cj.profile.profileFilter</filter-class>
</filter>

c) describe a mapping for this filter in web.xml
 


<filter-mapping>
  <filter-name>profileFilter</filter-name>
  <url-pattern>*.jsp</url-pattern>
</filter-mapping>

in this case filter will be on for the each .jsp file

And now when you invoke any .jsp page: http://your_host/your_page.jsp profileFilter will accumulate statistics: minimal response time, average response time and maximal response time per requested URI. Time values are in milliseconds.

d) describe ProfileServlet you will use for reports:
 


<servlet>
  <servlet-name>Profile</servlet-name>
  <servlet-class>com.cj.profile.ProfileServlet</servlet-class>
</servlet>

e) add a mapping for this servlet:
 


<servlet-mapping>
  <servlet-name>Profile</servlet-name>
  <url-pattern>/servlet/Profile</url-pattern>
</servlet-mapping>

Now any time when you run this servlet http://your_host/servlet/Profile you will see the real time statistics for your jsp files.

In your JSP files you can read accumulated statistics with the special custom JSP tags. See Profile filter taglib

You can add an intial parameter query to Profile filter. If this parameter is true than filter will count in query strings as well (so for example statistics for myfile.jsp?1 and myfile.jsp?2 will be calculated separately). E.g.:
 


<filter>
  <filter-name>profileFilter</filter-name>
  <filter-class>com.cj.profile.profileFilter</filter-class>
  <init-param>
   <param-name>query</param-name>
   <param-value>true</param-value>
  </init-param>
</filter>

Default value for this parameter is false (do not use query strings).

Also you can use Profile servlet in various forms:

1)http://your_host/servlet/Profile will print data
2)http://your_host/servlet/Profile?xml will return data in XML format
3)http://your_host/servlet/Profile?json will return data in JSON format
4)http://your_host/servlet/Profile?reset will reset the accumulated data

Note: the evaluation version accumulates up to 5 records

   For downloading:
    Profile package:  profflt.jar
 

 ©  Coldbeans     Comments?

Unrestricted version: Buy this component

See also JSOS - the largest collection of servlets and filters.

Also in JSOS: