First Java servlet

2008-08-18

As I mentioned on [twitter ](http://www.twitter.com/mattgrommes)today, I wrote my first Java servlet today. I had written part of a webapp using the Tapestry framework a few months ago but stuck and haven't gone back to it. This was a basic servlet to take a chunk of XML and send it via JMS to a queue for testing a new JMS integration architecture we're working on for work. It seems like everything in Java has some weird name that always makes me think it'll be harder and more complicated than it is. I'm used to Perl where you just drop a file in Apache and use CGI.pm to pull out the parameters. Turns out writing a servlet is almost that easy, although the setup to get all the files and classes deployed in Tomcat is much more complicated. Luckily I've done enough with Ant to hack a deployment script together and we have [an Ant expert](http://www.linkedin.com/pub/0/977/869) I can ask for anything hard. As usual, what I did was find a couple of examples and hack the heck out of them until I understood them and they did what I wanted. I did go through part of the first chapter on servlets from my [Head First Servlets & JSP](http://www.amazon.com/exec/obidos/ASIN/0596005407/mattorama) book that I had barely cracked the cover of before, so that's more research than I usually do ahead of time. Overall this basic servlet was pretty easy, although I know I just scratched the surface of the power and complexity available. Tomorrow I start working on figuring out how to send JMS messages. Luckily my team is incredibly good and I have good examples to hack on.

Code Work