Monday, 7 March 2011

Custom Filter/Servlet In ADF

Like any web application some time it is required to use custom filter/ servlet in ADF also. Here is the description of for my case. To use my custom filter I have created one Fusion Web application first.


Then I created my custom Filter named MyFilter.java. I have written my custom code in the overridden doFilter method of my custom filter.

I have used the below code in my doFilter method.

        long initialTime = (new Date()).getTime();
        filterChain.doFilter(servletRequest, servletResponse);
        long afterTime = (new Date()).getTime();
        System.out.println("Time To Process Request:"+ (afterTime-initialTime));


Here the filter is added in web.xml with filter name myCustomFilter. The screen shots are below. I want that every pages should pass through this filter. Any one can use directly <filter-mapping> also.



Now I have created one bounded task flow to design page flow from First Page to Second Page. I do not want to create the pages as page fragments. So I unselected this option.



I created the pages as viewq.jspx and view2.jspx . In view1.jspx I have added one button whoose action will redirect me to second page.








Now if I run the taskflow then I can see from the console(sysout from my Custom Filter) that it is showing time to process the requests.

The filters may be added in other ways also. This is just one example.

Please comment.



1 comment:

  1. Hi Moinak,
    thanks for the post. what are the other ways in adding filters in adf?

    ReplyDelete