Saturday, August 21, 2004

Tomcat as an application platform: enjoy the simplicity

As a Java developer, I mostly do what people directly pay me to do. Because of this, my comments here might be a bit biased: almost all of my work now involves writing either dynamic web applications or some type of infrastructure for web applications.

I find myself now really disliking writing thick client applications in Java (or Windows, X Windows, or Mac OS X for that matter). I started a long period of writing GUI client apps in 1982 when SAIC bought me a Xerox Lisp Machine - it was so easy to rapidly prototype GUI applications, that I found myself coding lots of demos. I also had to write Microsoft Windows, X Windows and Macintosh native GUI apps for many years.

Maybe I just enjoy doing whatever I am currently doing, but more than that, I just find writing web applications to simply be fun. Keeping code and data on the server just gets rid of all sorts of problems that take the fun out of development: handling updates, diagnosing bugs that are often related to a funny state on a PC, etc.

While there is a definite place for J2EE components like EJBs, JMS, etc., fortunately, for most of my work, I just deal with application specific POJO ("plain old Java objects") classes, simple persistence (e.g., Prevayler, Hibernate, etc.), JSP/struts, etc. In other words: the simple stuff that allows me to simply think about my current application, spending very little time worrying about infrastructure. Even SOA ("service oriented architectures") applications are straightforward with axis SOAP support, WSDL support, XML-RPC, etc.

And yes, Tomcat combined with a good web app development environment (I prefer IntelliJ 4, but Eclipse with MyEclipse is handy also) is good enough, and fairly much worry free.

PS. something obvious, but sometimes overlooked: when building applications on top of Tomcat, it is also easy to handle background processing: write a servlet that is loaded automatically by Tomcat (use a load-on-startup tag in your servlet definition in your web.xml), define your own init(ServletConfig config) method that after calling the super class init, starts up a work thread. I use this whenever I want to do background processing (periodic admin, web scraping, etc.) in a web application. Don't forget to increase Tomcat's heap storage using something like JAVA_OPTS=-Xmx300m in your catalina startup file.

No comments: