example

How to use the Commons IO project to create, delete, and move files and directories

I wrote the following Java class today that is a "helper" class for a project I'm working on to create a web interface for Nagios. The Nagios part isn't too relevant, because mostly what I'm trying to show here is how to use the Apache Commons IO project to make it easier to interact with files and directories from Java code.

In short, the following Java class shows how to use the Commons IO project to accomplish the following tasks. Without any further delay, here is the complete source code for my class:

How to perform a case-insensitive database query

Database FAQ: How do I do a case-insensitive database search?

Answer: When performing a database search using MySQL, PostgreSQl, SQL Server, Oracle, etc., I convert the results of the query to uppercase using the UPPER function, and make sure my search parameters are also in uppercase. Here's an example of how I do this when searching on the first_name field of an Employees database table:

Ant WAR task - A sample Ant build script that builds a WAR file

You'll probably have to know a little bit about Java, Ant, and build files for this sample build.xml file to be any use to you, but if you're looking for a sample Ant build script that can be used to create a war file, or one that simple uses a war task, this example might work for you.

I'm not going to provide any explanation of any of this right now, but if I have time in the future I'll come back here and add a few comments about how this build script works.

How to set the default input focus on a field in an HTML web form

When I create a web-based user interface I tend to be a fanatic about making sure that the first input field on a form gets input focus when the form is first displayed. It always drives me crazy when I go to a web form that requires text input, but the developer of the page hasn't taken the time to put the default focus in the first field of the form.

So ... after looking around at some HTML/JSF/Struts/JSP code I've written over the last few years, the following JSF example shows the most concise way I know of setting default input focus on an HTML form field:

Syndicate content