1. Introduction
The PDF of 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 mastered the basic concepts of web programming in Java.
To fully understand the exercises provided, the document [Introduction to Web Programming in Java with Servlets and JSP Pages (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:
- Install the tools, download the code from this document’s website, and run the suggested tests. A beginner will gain nothing from this approach. An experienced developer, however, may do so if they are only interested in testing the Eclipse/WTP development environment.
- Install the tools, follow the document, and perform the suggested tests by copying and pasting from this document. You do not read document [ref1]. By proceeding this way, you will begin to acquire the basics of web development, but certain points will remain unclear or mysterious. This is a viable method 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].
- Do the same as in 2, but read [ref1] when advised to do so. This slower method will eliminate some of the unclear and mysterious aspects of Method 2, but it does not prepare you well for independent work because the code obtained by copy/pasting will not necessarily be fully understood.
- We do the same thing as in 3, but we type all the code ourselves. This is obviously longer and more 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 error-free. 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 the 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 3-tier MVC architecture, which was barely touched upon in the original document,
- an example of a 3-tier MVC web application using data from a DBMS.
A 3-tier web application has the following structure:
![]() |
- the [DAO] layer handles data access, most often persistent data within a DBMS. But this can also be data coming from sensors, the network, etc.
- The [business logic] layer implements the application’s “business logic” 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 alone. Here, we provide an example using all three layers.
