Wednesday, February 29, 2012

Integer overflow in Java

What would happen in Java when you increment an Integer variable that already contains its maximum value?

Tuesday, February 21, 2012

Log4j filter to mask Payment Card numbers (PCI DSS)

According to PCI DSS (Payment Card Industry Data Security Standard) your application must not store payment card numbers. This requirement includes database, files and logs. The following filter will allow you to mask card numbers in your logs on the fly, so even if you accidentally turned debug mode on for network communication, you can be confident that your data is PCI compliant.

Sunday, February 19, 2012

Stop reinventing wheel, use Apache Commons

Developer's life is full of routine tasks. We need to validate strings, convert data from different formats, compare objects and so on. Some developers tend to write everything on their own, reinventing common algorithms again and again. Every Java developer should look at Apache Commons Lang library as it already has everything we need every day.

Wednesday, February 8, 2012

NetBeans: syntax highlighting for html templates with unsupported file extension

NetBeans editor supports syntax highlighting and validation for several languages as Java, PHP, JavaScript, HTML. But if your file has different extension e.g. .template, NetBeans is unable to recognise the language. What you have to do if you want to turn on highlighting for Smarty or Velocity templates?

CloseUtils: closing resources silently

When working with resources in Java it is important that they are closed after use. Usually it is done by calling close() method in finally block. The problem is that close() method can throw an Exception. The following class allows you to close resources silently, so you save some try-catch lines.

Sunday, February 5, 2012

Integrating Wicket with Spring

In this short example I will show you how to integrate Wicket 1.5 with Spring 3. Wicket is a rich web framework that allows creating web applications using simple html and Java code. Wicket has its own IOC/DI engine, but Spring has become a de-facto standard for service layer.