GZIPFilter and OC4J

Filters seem to work different in OC4J than in Tomcat. I’m running OC4J version 9.0.3 and Tomcat 4.1.30, same J2EE version i think, so they should behave the same, but somehow they don’t.

The problems occur when one struts action forwards to another, instead of to a jsp page. For example, I have one action checkaccount, which validates the username and password entered by a user, and if it’s incorrect the login jsp is displayed. When the values entered by the user are correct i forward (by specifying another *.do page in the struts config) to another action, which fetches some data and then displays a table of contents jsp.

I’ve specified that the GZIPfilter should applied to every *.do url, so that the output generated by an action will be compressed. When logging in correctly the following happends in tomcat:

doFilter> /prismant/checkaccount.do
GZIP supported, compressing.
writing...
writing...
writing...
writing...

But in OC4J the following happends:

doFilter> /prismant_dev/checkaccount.do
GZIP supported, compressing.
doFilter> /prismant_dev/overzicht.do
GZIP supported, compressing.
writing...
writing...
writing...
writing...
writing...
writing...

As you can see, tomcat executes the filter only once, whereas OC4J executes it twice. In the browser, the html generated by tomcat displays correctly, but when using oc4j the browser displays a lot of nonsense. Maybe because the html page is compressed twice, and the browser only decompresses it once?

Update Setting the redirect attribute of the action forward in the struts config to true seemed to solve the issues, but caused another one. Action chaining doesn’t work anymore, as some of the url parameters are no longer valid. The struts documentation recommends that action chaining should not be used, but I don’t really agree. Using action chaining i can change the pageflow of the application by just altering the struts configuration. No code changes are required. If i don’t just action chaining i have to modify to code everytime the page flow needs to change.

blog comments powered by Disqus