To expand a little on Paul's comments:
There can be occasions when writing a CGI program in Java makes sense. In particular in cases where the overhead of starting a new JVM is small compared to the benefits gained from the power and flexibility of Java.
On a reasonably specified system, starting a Java program should take no more than a second or two (try it out by timing a "hello, world" application). If you need to quickly write,
test and deploy some complex (or just slow) Java code which uses a lot of pre-written classes, writing it as a CGI may be the right choice.
On the other hand, though, setting up and using an appropriate server and servlets is a much better long-term solution. Typically in such systems all the overhead of starting the JVM
and initialising your part of the system (opening database connections, reading initial data, setting preferences and so on) are done just once, when the servlet is loaded by the server. Each normal "hit" does just the actual processing required.
This can mean that a servlet system is even faster than a comparable CGI program written in Perl, C++ or any other language.
As a concrete example, I put together a simple "requirements capture" system for where I work. The first prototype used CGI and was written in Bourne shell and Perl. To add a new entry took about 6-7 seconds (it's not a fast box that the server runs on - a 25MHz Sparc LX, running Solaris 2.6). Converting that to Java servlets reduced the response time down to about 300 ms. I also find Java easier to write and maintain than Perl, so I was better situated to implement new features when required.
Finally, if you have any more servlet questions, may I recommend that you ask them in the "servlets" section of this board, which I have recently taken over as moderator.
I hope this has helped.