Two Servlet Filters Every Web Application Should Have
Subject: Two Servlet Filters Every Web Application Should Have [Nov. 19, 2003]
Date:   2003-11-21 08:09:20
From:   anonymous2
Response to: Two Servlet Filters Every Web Application Should Have [Nov. 19, 2003]

There are a few important points I'd like to make and they are listed with the more important points first. The first is you should almost always use some sort of caching and compression. The second point, is that it should be easy. And the third point is that it should be flexible.

About the first point. There are many ways to cache/compress content. Apache can do it, as can most any decent web server. You will certainly benefit no matter what you choose to use.

About the second point. The filters I presented are about as simple as they come, and they are 100% portable on any Java web app -- Apache backend or not. If you are doing Java web app development, you can configure these two filters once and simply reuse it for every other Java web app you ever make. All the deployment issues are transparent. I like this quite a lot because it means there are fewer configuration issues to worry about when setting up a new project, especially if you must use specific J2EE sever X or not-Apache solution Y.

About the final point. If you bundle cache/compression code in with your primary development environment you can do just about whatever you like. Modifying these two filters to do some sort of odd-ball functionality is near trivial for a Java developer, which hopefully you are if you are using them.... However, if I don't want my Apache (or other server) gzip support to compress content on the third day of the month, when requests are coming from my IP, and if I'm logged in to the web app as admin, it is near impossible to do.

So let me rehash. However you do this stuff is great. But, if you are working with Java web apps, something like these two filters is probably the ideal.

Jayson Falkner

Full Threads Oldest First

Showing messages 1 through 3 of 3.

  • Two Servlet Filters Every Web Application Should Have [Nov. 19, 2003]
    2003-11-22 21:20:24  anonymous2 [View]

    FYI. I'm a Java programmer for a bank in Omaha, NE. We recently had a bunch of strange bugs pop up during testing. Our app is about 4 years old, and we'd never seen this behavior before. (Basically, we could tell that CSS and Javascript libraries were failing to load on the browser end). A little research turned up a known bug in IE - apparently Microsoft's browser sometimes chokes on compressed CSS files and JS libs. We checked our web server (IIS), and sure enough, someone had turned http compression on. Needless to say, we turned it back off, and we won't be able to use compression until the IE bugs are fixed. (Although the bug appears in IE 5.0, 5.5, and 6.0 at least, so I don't have much hope it will be fixed soon.)

    Your filter may not cause the same problem, but it's something people should be aware of.
    • Two Servlet Filters Every Web Application Should Have [Nov. 19, 2003]
      2003-12-01 01:23:51  anonymous2 [View]

      IIS is not very bright when it comes to compression. Bascially they don't seperate it from the Caching part, making all things suddenly have weird cache control headers in their compressed state, when they had none before.

      Although... I have used Apache with gzip compression of everything (except jpgs) for 4 years, and have yet to have a problem with IE/x.x.

    • Two Servlet Filters Every Web Application Should Have [Nov. 19, 2003]
      2003-11-24 14:52:26  anonymous2 [View]

      If you look at the examples you will notice that compression is only enabled on *.jsp and *.html files...