Alvin Alexander | Java, Scala, Unix, Perl, Mac OS X

I was scanning over a Java performance programming book the other night, and it reminded me about a javac compiler option I had forgotten about. The short story is that they suggest you can use this command:

Aah, case-insensitive searching is added, as well as some utilities to help search engines. Here's a table of PostgreSQL regular expressions.

Here’s a quick note about using Postgresql regular expressions and its regular expression syntax.

If you’re familiar with Unix and Perl regular expressions, these are very similar, so it’s an easy pickup, and a very powerful way to search for data in Postgres. Just use these regular expressions with SQL SELECT queries instead of the LIKE operator, and you’re ready to go.

Postgresql regex syntax

Here’s a little table of the Postgresql regular expression operators I have used:

For those in need, here's a step-by-step tutorial on asking a girl for a date.

On a more serious note (or not) the following link contains some nice interaction design patterns, or what we call "Web UI" design patterns. Kudos to Martijn van Welie; if I had to be Siskel and Ebert I woudn't disagree with much of anything here.

Here's a heart-warming story of a dog sharing her love on my birthday.

I started looking into making my “blog” software use case-insensitive searching. I thought that would make the “Search” facility for this site much more powerful.

The secret to Postgresql case-insensitive searching with SQL SELECT queries is to use regular expressions. If you’re used to standard Unix/POSIX regular expressions, the implementation is pretty easy as well. Instead of using the standard database LIKE operator, the solution is to use the Postgres ~* operator.

Here's an example of how to forward from a servlet to a JSP in your J2EE code. I can never remember how to do a forward like this when I need it, so even though this example is pretty easy, I've put it out here so I can find it later.

The typical scenario is that you're working on a Java servlet, and you need to forward the user from that servlet to a JSP. Assuming the name of the JSP is "searchResults.jsp", here's the code that will forward from your servlet to that JSP:

If you haven't seen it, offers an HTML Validation Service for free that is pretty cool. Give it a URL, and it calls the URL and checks the document for errors and HTML validity. Of course this page bombed the big one, but I'm still in a major rebuild process here, so I'm not sweating too much as long as it renders in IE and Mozilla. They also offer a CSS Validator that I haven't had a chance to test yet. That one also appears to offer a download.

So today I learned that you can't just access PATH_INFO (pathinfo) information from a servlet when you're using Tomcat (at least not Tomcat 3.2.4 running under Apache). I can access the PATH_INFO information okay under Tomcat running standalone on my PC, but for some reason the same config did not work properly using Tomcat under Apache. (I'll investigate this more in the future.)

Specifically, for me to be able to access PATH_INFO (PathInfo) information in a servlet, I had to add this servlet mapping information to my web.xml file:

This is an easy task. For the purposes of this exercise assume (a) the high-level directory of your project is named "MyProject", and (b) that you are on a Unix computer, and (c) that your "MyProject" directory is in your home directory on your Unix system. With these simple assumptions, just follow these steps:

  cd MyProject
  cvs import -m "your description here" MyProject alexander start

If everything works ok, you should see a message that says something like "No conflicts created by this import."


Java/JDBC try/catch/finally exception FAQ: Can you show me a decent example of how to catch a JDBC exception in a try/catch/finally block?

Beauty is in the eye of the beholder, but here's a JDBC example showing some Java code that uses a try/catch/finally block with a Java JDBC query:

Java Properties file FAQ: Can you show me how to read a Java Properties file?

Here is a snippet of Java source code that shows how to read a Java Properties file named It reads in two properties named CRUST and TOPPINGS.:

CVS checkout FAQ: How do I get a snapshot of a CVS repository back to a certain date?

To solve your first problem, let's assume that yesterday was September 14, 2001, and your project name was KickStart. To check out the code from your KickStart repository from late last night, use this cvs checkout (cvs co) command:

"CVS tag" FAQ: How do I tag a release of a software project with CVS?

Assume that you have a software project named KickStart checked into a CVS repository. Further assume that you want to tag the current release of the project with the name "Release-2001_09_15". Here's how to tag that release with the "cvs tag" command:

Several times when working with CVS I've forgotten to check a binary file into CVS with the binary file flag. Fortunately this problem can be fixed using the cvs admin command. It's just important to remember that fixing this problem is a two-step operation.

CVS binary file FAQ - How do I add a binary file to a CVS repository?

Answer: You add a binary file to a CVS repository with the cvs add command, like this:

cvs add -kb


CVS remove FAQ - How do I move or rename a file that is checked into a CVS repository?

Good question. This is neither obvious or straightforward with CVS. It also requires administrator priviledge.

cvs remove example - how to move a file

To move a file that's checked into CVS and save it's revision history, do the following:

CVS FAQ - How do I go back to a previous version of a file?

Solution: What revision would you like to revert to?

Let's see ... I just messed up revision 1.25, so I would like to go back to version 1.24.

And what is the name of the file?

Move to the directory where your file is located, then run this command:

JBuilder FAQ: Is there a way I can see the parameters a Java method expects?

Yes, assuming that your cursor is position right after the opn parenthesis, type this magic keystroke:


You will see a list of parameters that the method accepts, and it will not disappear right away.

How did you know that?

I found it one day in the JBuilder menu system. I also heard it at the Borland Developer Conference.

To browse a symbol when using JBuilder, you just need to use the magic keystroke: [Ctrl][Enter].

Java number formatting FAQ: How do I format numbers for output on reports in Java programs?

Generally speaking you want to use the Java NumberFormat class and its descendants, such as the Java DecimalFormat class.

Quoting the API documentation, the Java DecimalFormat class "also supports different kinds of numbers, including integers (123), fixed-point numbers (123.4), scientific notation (1.23E4), percentages (12%), and currency amounts ($123). All of these can be localized."