23. dec. 2004

ONJava.com: The Hidden Gems of Jakarta Commons

The Hidden Gems of Jakarta Commons
If you are not familiar with the Jakarta Commons, you have likely reinvented a few wheels.

Before you write any more generic frameworks or utilities, grok the Commons. It will save you serious time. Too many people write a StringUtils class that duplicates methods available in.
This article gives some examples and tips.

21. dec. 2004

TheServerSide.com - Struts Live Chapter: Nested POJOs

The new chapter will include a solution to one of the most frequently heard complaints about Struts: that it doesn't provide a simple way to meaningfully nest POJO graphs in ActionForms. The provided example code solves this problem and includes an integrated solution for automating conversion, formatting, and validation.

Read the article in PDF here:Struts Live Chapter: Nested POJOs.

20. dec. 2004

Yet Another Servlet Filter You Can't Live Without - Cache control

The Cubicle Jockey: Yet Another Servlet Filter You Can't Live Without
At work, we were looking for ways to reduce bandwidth usage on our secure applications. We already have the compression filter, various object caches, etc-- everything you read about. Then we started looking into caveats with using SSL and found something surprising-- HTTP 1.1 SSL usage prevents ANY content from being cached on the user's drive. "So you mean those massive JavaScript and Stylesheet files are getting pulled down with each secure page?" Yes, images too-- multiple times on a single page even.

The solution? Yet another Servlet Filter you can't live without that will be bound to your static content such as Javascript, CSS, and image files. The code for the filter is only a couple lines, but the goal is to write out the 'Cache-Control' header and the 'Expires' header.

long durationSeconds = 28800; // 8 hours
response.setDateHeader("Expires",
System.currentTimeMillis()
+ (duractionSeconds * 1000));
response.setHeader("Cache-Control",
"public, max-age="
+ durationSeconds);
chain.doFilter(request, response);


I couldn't believe how much bandwidth we are now saving with our SSL applications.

Read more here.

Write custom appenders for log4j

Write custom appenders for log4j.
Extend log4j to support lightweight over-the-network logging.

The Apache Software Foundation's log4j logging library is one of the better logging systems around. It's both easier to use and more flexible than Java's built-in logging system. This article shows you how to extend log4j with a custom "appender," the part of the system that actually writes the logging messages. This article also provides a simple example of Java's socket APIs and multithreading capabilities.

1. dec. 2004

Unit Testing with Mock Objects : What are Mock Objects?

Unit Testing with Mock Objects : Shine Technologies.
This page and its children talk about unit testing with the Mock Objects pattern. In particular, it covers what Mock Objects are, what tools the author (Ben Teese) have used, and important lessons he has learnt along the way.


The pages is about:

  • What Are Mock Objects?
  • DynaMock - A Mock Object Testing Framework
  • Experiences With Mock Objects
  • Conclusions on Unit Testing with Mock Objects