Friday, December 23, 2005

Using Eclipse to build Webapps

As much as I enjoy doing things by hand, I've realized that it's important to be efficient. Doing things by hand isn't necessarily very efficient. Which is why we have tools. It's easier to build a house with a pneumatic nail gun than it is with a hammer. There's obviously some overhead to doing things with more sophisticated tools, but often, the overhead is a minor concern. It usually becomes overshaddowed by the gained efficiency and rate at which things can be done.

For this reason, I've decided to lay asside my beloved UltraEdit and use Eclipse for developing my Java web applications. There's going to be a learning curve to be sure, but that's ok. I look at it as an investment. Investments are expensive, but in the long run they pay off. If everything goes well, that is. To help out, I found a good tutorial, which seems to address the goals I want to accomplish. It teaches how to use Eclipse to develop Struts applications for Tomcat. Just what I wanted.

Among the relevant tasks in this tutorial is setting up a plugin to connect Eclipse to Tomcat. This Eclipse plugin for Tomcat is available from sysdeo.com This plugin helps to create Tomcat-specific projects and start, stop and restart Tomcat.

After going through the above tutorial, however, there are a couple of things lacking. First is the lack of directions for building a servlet. To do this, you just need to go to File>new>class. This will start a new class. At that point, you can create a Servlet. I looked around for a while trying to figure out how to "build" or "run" the servlet, but there's no way to do this in Eclipse. Instead, going to the url that you define in the servlet mapping should do the trick. It took me an hour or more of fumbling around to figure it all out.

Additionally, the struts examples seem to be a bit out of date. When I tried this tutorial out, I used Struts 1.2.8, and the issue that the author mentions about the applications.properties file is irrelevant. As such, following the directions about changing the source location just causes problems. There's probably more going on there than I understand though.

All in all, after doing this tutorial, things are a little more clear. I don't know if I like this particular plugin for creating web applications though. I might try something different. I don't know if I like the way it sets up the development directory structure. What I'd really like, is a plugin that keeps the source out of the deployment environment, and allows me to deploy a war file. However, this plugin is nice in the way that it controls Tomcat. But there's gotta be something different. The search begins!

No comments: