Jan 19

Servlet and JSP Head FirstEvery now and then I go back to trying to learn Java web programming.

Mine is a long story. I started college a long time ago, and I was going to study CS. I did well, but my parents thought CS was a career that was dead, there were too programmers, engineers, etc. Beside the fact that my parents were off, I majored in marketing and later got my MBA, which is the source of everything evil that happened to me later (and never made any money anyway.

So I went back to college to learn Java. I did great and gained some more credits but I always felt they were telling me half the story. The professors were more interested in the order of the mathematical operators than real life use, such as using ORM or the infamous Java I/O system.

One day I became especially frustrated with object serialization, and in order to understand the subject I took a peek into Python (Bruce Eckel kept saying in his books how good Python was). In took less than two or three days to learn enough Python to challenge my previous Java lessons, and found the language incredibly refreshing and innovative. From Python I jumped to Rails (and then to Ruby, which I think it is the way many people arrived to Ruby) and have been the happiest person ever. Only the combination of Rails/Ruby/community could spring forth the revolution that we have been watching for the last two years.

Yet recently I went back to Java, motivated by the great book Head First Servlets and JSP by Bryan Basham, Kathy Sierra and Bert Bates. I was surprised to learn in the first 100 pages what I was never able to learn in probably 2,000 pages of literature from Sun. I even joined the J2EE with Passion seminars from Sun. I got all the free literature from all the sites and followed the weekly homework, learning that it was a real pain in the butt to make simple Hello World! web application.

It is easy to understand how later I learned Rails over the weekend and never looked back (until last week).

What is amazing is how in the first 100 pages this OReilly book can so clearly and simply explain the basics of Servlets and Java Server Pages. Using examples from old kung-fu movies OReilly does several things rights.

First, they explain web applications in a slow, simple way, without jumping to overly complicated technical jargon ahead of time. I have a book at home that explains the servlet abstract class and its different methods before explaining what a servlet is good for. Instead, HFSJSP takes a different approach, leaving the technical and complicated for later.

Second, they explain the basics a bit at a time. Then they fill the details later. This is similar to my above comment, but works quite differently. For example, they explain web descriptors starting out with simple xml files to name servlets according to the class, url and servlet name. The explanation and how this maps in real life web applications is so concise it took less than two pages to understand (and I keep even today hundred of pages explaining all that crap and I still do not get it… the comparison is like some cryptic language versus plain old English.)

Third, finally someone explains the directory structure beforehand examples! It is so darn easy to understand the whole schema when you know what goes exactly where. This is important if you look at the Rails directory structure where you know exactly what goes where. For example, controllers go inside app/controllers; images go in public/images; etc.

Building in spiral is a great way to get a concept across, and I can not think of a better subject than Java Servlets and JSP to be explained gradually and slowly (no wonder most major web projects I know are done in PHP, Perl, or .NET, when not in Rails or Django)

I am not interested in passing any certification exam, but I certainly would recommend this book as if you could only get one book on Java web programming, get Head First Servlets and JSP.

written by Administrator