Let’s start at the bottom…

    Kevin Yank
    Kevin Yank

    As I have mentioned, Java Web technology has been built up in layers over many years. Today, there are at least a dozen practical and proven approaches to building Web sites with Java.

    My first goal in this blog will be to take you on a grand tour of these options, to give you an understanding of each–its strengths and its weaknesses–so that you can begin to make informed decisions about what to learn.

    So we’ll start by looking at Servlets, then we’ll move on to JSP, combine the two as we examine Model 2, extend this to a discussion of MVC frameworks like Struts and Spring, and evenutally explore the various View technologies like Velocity, JavaServer Faces, and XMLC. This is by no means an exhaustive list–there is lots to explore!

    As we do this, I predict you’ll notice an interesting trend. Most Web development platforms start out reasonably easy to learn and use, but they tend to get more and more complicated as you try to shoehorn larger, more practical and complex projects into them. PHP comes to mind: much as I love that language’s ease of use, you can spend months reading people’s thoughts on how best to structure sizeable projects and still not come up with a clean solution.

    The trend with Java is different: there is a lot to learn up front, and at first simple tasks can seem stupidly labour-intensive. But as you grow comfortable with the layers of complexity, they begin to work for you, and projects that you used to find intimidating will start to seem easy.

    To begin our tour, we’ll start with a dead simple Web application: a database-driven To-Do List. We’ll be building this same application with each of the technologies we explore, and I’ll provide downloadable code for each version. Because this is a simple project, it will allow you to focus on the differences between the techniques, their strenghts and weaknesses, which features are easy to implement, and which are hard.

    Each incarnation of this application will rely on the same MySQL database, so let’s start with that. If you plan to follow along, now’s a good time to make sure you have a healthy MySQL installation on your development machine. If you’re really new to databases or server-side Web development in general, you can find a solid introduction to MySQL with full installation instructions in the first two chapters of my book, Build Your Own Database-Driven Website Using PHP & MySQL. These chapters are available as free articles on sitepoint.com: Chapter One and Chapter Two.

    With MySQL in place, create a new database (I’ll call it ‘todo’) with the following single table in it:

    CREATE TABLE todo (
    todo VARCHAR(255) NOT NULL

    Tomorrow, I’ll present the Java classes that will interface with this simple database.