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

Just returned from a short trip to the northern outskirts of Chicago, Illinois. Wow, can it rain.

On the computer side of life, have you ever found yourself needing a copy of the stuff (source code, etc.) in a CVS repository, without all the CVS admin files? Here's a quick tutorial on how to use the cvs export command.

Can I get a copy of the source code (without the repository)?

The other day someone not familiar with CVS asked if they could have a copy of the source code for the DDConnectionBroker project, an Open Source project from DevDaily.com. I said sure, I'd be glad to provide a copy of the source code, stripped of all the CVS directories/files. To do this, all I had to do was run the "cvs export" command.

One of my favorite Java subjects is code optimization and performance. Here I'd like to show you a couple of neat things you can learn with the javap -c command. This command lets you disassemble Java bytecode.

The first thing you need to have for this exercise is a little sample Java code. So in the examples below I create two test Java classes, appropriately named Test1.java and Test2.java. Although it's not explicitly stated below, the steps I'm going to follow are these:

On Saturday, May 4, 2002, the day of the Kentucky Derby, Jim Kimmel, a friend and co-worker, passed away. He had a heart attack while doing something he loved, riding his bike with his friends. You are missed very much Jim.

So today is the big day, the fastest two minutes in sports, and I need to start cooking for the party. If the race doesn't interest you, maybe my Java and OO programming reading list might suit your style. Place your bets...

Alistair Cockburn has been a focus of my OO reading for a while. Find out why at his home page, and two other sites he has set up, usecases.org and crystalmethodologies.org.

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, w3.org 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
  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 Pizza.properties. 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: