Skip to content

1. Introduction

The PDF for this document is available |HERE|.

The examples in this document are available |HERE|.

This document aims to introduce the basics of MVC web programming in Java using servlets and JSP pages. After reading this document and testing the examples, the reader should have acquired a grasp of the basic concepts of web programming in Java.


To fully understand the exercises provided, the document [Introduction à la programmation web en Java avec les servlets et les pages JSP (2002)] may be helpful. The reading recommendations provided at the beginning of certain sections refer to this article. This document will be referred to as [ref1] hereafter.


This document can be used in various ways:

  1. Install the tools, download the code from the website linked in this document, and run the suggested tests. A beginner will gain little from this method. An experienced developer, however, may do so if they are only interested in testing the Eclipse / WTP development environment.
  1. Install the tools, follow the document, and perform the suggested tests by copying and pasting from this document. Do not read the [ref1] document. By proceeding this way, you will begin to acquire the basics of web development, but some points will remain unclear or mysterious. This is a viable approach if you want to move quickly with the intention of delving deeper only later, when writing a personal application and perhaps using a reference document other than [ref1].
  2. We do the same thing as in 2, but we read [ref1] when it is recommended. This slower method will eliminate some of the unclear and mysterious aspects of method 2 but does not prepare you well for independent work because the code obtained by copy/pasting will not necessarily be fully understood.
  3. We do the same thing as in 3, but we type all the codes ourselves. This is obviously more time-consuming and tedious but very effective. To type the code, you have to read it, which requires paying attention to the code and, by extension, begins to foster understanding. This manual retyping will rarely be done without errors. These errors, which will be flagged by various Eclipse tools, will prompt the reader to question the code they’ve written and thus understand it better.

This document incorporates a significant portion of an article published in January 2005 titled "Web Development in Java with Eclipse and Tomcat" and available at url [http://tahe.developpez.com/java/eclipse/]. The contributions of this document are as follows:

  • the use of the Eclipse WTP plugin for web application development,
  • a reorganization of the document to emphasize the MVC 3-tier architecture, which was barely covered in the original document,
  • an example of a 3-tier MVC web application using data from a SGBD.

A 3-tier web application has the following structure:

  • the [dao] layer handles data access, most often persistent data within a SGBD. However, this can also be data from sensors, the network, etc.
  • The [metier] layer implements the application’s “business” algorithms. This layer is independent of any form of user interface. Thus, it must be usable with a console interface, a web interface, or a rich client interface. It must therefore be testable outside the web interface, particularly with a console interface. This is generally the most stable layer of the architecture. It does not change if the user interface or the method of accessing the data necessary for the application’s operation is altered.
  • The [web] layer, which is the web interface that allows the user to control the application and receive information from it.

The article [http://tahe.developpez.com/java/eclipse/] provides only examples of web applications limited to the [web] layer. Here, we provide an example using all three layers.