We want to create a small web application (library), that illustrates the usage of JavaServer Pages combined with Java Servlets. We use the JavaServer Pages to display data (presentation) and the servlets to control and call the business logic of the web application.
First we shortly explain the characteristics of these two technologies.
Generals
Author:
Sascha Wolski http://www.laliluna.de/tutorials.html Tutorials for Struts, EJB, xdoclet and eclipse.
Date:
September, 23th 2004
Source code: http://www.laliluna.de/assets/tutorials/java-servlets-jsp-tutorial.zip The sources does not contain the project files. So create a project first and copy the sources to this projects.
PDF Version des Tutorials: http://www.laliluna.de/assets/tutorials/java-servlets-jsp-tutorial-en.pdf Development Tools
Eclipse 3.x
Optional:
MyEclipse plugin 3.8
(A cheap and quite powerful Extension to Eclipse to develop Web Applications and EJB (J2EE)
Applications. I think that there is a test version availalable at MyEclipse.)
Application Server
Jboss 3.2.5
You may use Tomcat here if you like.
Java Servlets
Servlets represent java programs that run on a web server. They allow the developer to produce dynamic web sites with java.
A Servlet has the following tasks
•
It reads and processes data, which a user inputs in a HTML form on a web page.
•
Other informations can be processed, e.g. what browser or system will be used.
•
It generate results with the existing data, calls the business logic directly in the servlet or another class, which contains the logic or executes a database query.
•
The results are formated. If the Browser expects an answer in the HTML format, then the results must be formatted in accordance with the standard. It is possible to return different formats of data with a servlet. (gif, jpeg, doc, etc.).
•
Suitable answer parameters are set. Befor the servlet