Debugging a Struts application
So I'm fixing a legacy application. One problem I'm having is that the status label on the web page does not get updated from "Processing..." to "Complete" for some of the input files even though the Java code has finished. I've noticed that in the bad cases, the doFilter() method keeps getting called in the bad case multiple times even after the real work has finished. I want to find out what keeps calling doFilter(). Unfortunately, when I print a stack trace to the log, it only goes so far back and everything is a library call, so tracing it backwards meticulously seems to be blocked.
Any suggestions how I can find where doFilter() is getting called? (Doing a reference check gets 0 hits.) Or, lacking that, suggestions for other approaches to find the root of the problem?
It's been a while since I wrote JEE (which is what I'm going to assume you're using) so some of the details may be fuzzy, but you can check here or here for more information. I don't think it changed much in later versions of JEE either?
doFilter(...)is the main method of the JEE
Filterinterface. This is a filtering mechanism for webapps, used to modify the response from a servlet or JSP or similar server side code. For example, you could write a filter to set the
Content-Typeheaders in the
HttpResponseobject. The method is called by the web application framework after it calls the code to generate the page, based on the
web.xmlor whatever configuration for your application, specifying which path (static or regular expression) it should match and filter, like anything under
What this means is that you need to check the application configuration to see what URLs will trigger it, then look for places in the application that forward or redirect there. Since its being called multiple times, there could be a redirect loop, maybe the
doFilter(...)processing is causing the filter to be called again.
Best I can remember, hope thats helpful...? Oh, and apologies if you already knew all that stuff about filters.
Thanks grkvit. No, I didn't know anything about filters. I solved the problem by approaching it from another direction - progressively changing the data from an input file that didn't have the problem to one that did. It turned out that it was a straight-forward error in my code that I had written temporarily as a test, and forgot to come back and deal with the edge cases.