This project uses containers to provide an example development and testing environment.
tomcat- a tomcat 10.1.x container, built to include the documentation and examplesdbs- a MariaDB container, using docker volume,jsp-bookstore-dataadminer- a database WebUI managementjsp-net- dedicated docker network
The example Tomcat application is based
on tomcat-containers and
JSP Servlet JDBC MySQL Create Read Update Delete (CRUD) Example
but makes no reference to Eclipse , nor how the code was developed.
The application has been converted to HTML5 and makes use of Pure.CSS downloaded from a CDN to do some simple formatting.
To illustrate static content an Almost background is also used.
The tomcat container listens on port 8480, not the default 8080 to avoid port conflicts.
The Java development was done with IntelliJ IDEA Community Edition.
Maven is installed locally on the development laptop, although it is possible to containerize
it, Apache Maven is a software project management and comprehension tool or use
the bundled IntelliJ IDEA Maven
The maven plugin org.codehaus.cargo.cargo-maven3-plugin is used to un/deploy the WAR file.
The following applications need installed locally, Docker Desktop and Maven
To create the Bookstore database andbsapp application account, see MariaDB
To use the environment and start/stop the Docker containers
PS C:\Users\sjfke> docker create volume jsp-bookstore-data # MariaDB persistent volume
PS C:\Users\sjfke> docker compose up -d # Start the containers
[+] Running 4/4
✔ Network tomcat-jsp-servlet_jsp-net Created 0.1s
✔ Container tomcat-jsp-servlet-adminer-1 Started 0.7s
✔ Container tomcat-jsp-servlet-dbs-1 Started 0.6s
✔ Container tomcat-jsp-servlet-tomcat-1 Started
PS C:\Users\sjfke> start http://localhost:8480 # Tomcat; Manager u:admin p:admin
PS C:\Users\sjfke> start http://localhost:8491 # Adminer u:root, p:r00tpa55
PS C:\Users\sjfke> docker exec -it tomcat-jsp-servlet-dbs-1 /bin/bash # Login to MariaDB container
PS C:\Users\sjfke> docker compose down # shutdown the containersThe compose.yaml specifies al the container settings, including the MariaDB password.
To start just the MariaDB and Adminer containers use:
compose-mariadb.yamlpasswords etc. are read fromenvfoldercompose-mariadb-simple.yamlpasswords etc. are hard-coded in theyamlfile
The Wharf folder contains README files, covering the detail of the local setup, such
as DOCKER,
MAVEN, MAVEN_DEPLOYMENT, TOMCAT_MAVEN
and MARIADB
To set up Tomcat for development, the contents of the Config folder are used.
This make docs, examples, host-manager and manger available and accessible on the Docker IP subnets.
Two user roles are created, with the password being the same as the account name.
adminforhost-managerandmangerbadminfor the Manager HTML interface
The tomcat-users.xml
<?xml version="1.0" encoding="UTF-8"?>
<tomcat-users version="1.0" xmlns="http://tomcat.apache.org/xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd">
<user password="admin" roles="manager-gui,manager-status,admin-gui" username="admin"/>
<user password="badmin" roles="manager-script,admin-script" username="badmin"/>
</tomcat-users>Tomcat 10 onwards requires the JSP pages use <%@ taglib uri="jakarta.tags.core" prefix="c" %>
There is contradictory advice on the required Maven dependencies, furthermore Tomcat 10.0.x,
Tomcat 10.1.x and Tomcat 11.x require
difference dependencies.
Using incorrect
mavendependencies often results injava.lang.NoClassDefFoundError: javax/servlet/jsp/tagext/TagLibraryValidatorerrors.
Tomcat Maven Dependencies provides the correct dependencies for each version of Tomcat
Two approaches are described
But it is the maven-3-cargo-plugin that is used.
Tomcat 10 onwards requires the JSP pages use <%@ taglib uri="jakarta.tags.core" prefix="c" %>
Using an incorrect maven dependencies often results in
java.lang.NoClassDefFoundError: javax/servlet/jsp/tagext/TagLibraryValidator errors.
There is contradictory advice on how to set up this properly, and furthermore Tomcat 10.0.x, Tomcat 10.1.x and
Tomcat 11.x require difference dependencies, so read Tomcat Maven Dependencies to
avoid many wasted hours.
To build the Bookstore-0.0.1-SNAPSHOT.war file from the command line
PS C:\Users\sjfke> mvn clean package # create war file
PS C:\Users\sjfke> mvn cargo:undeploy # remove bookstore application on tomcat container
PS C:\Users\sjfke> mvn cargo:deploy # deploy bookstore application on tomcat containerTo view the bookstore web application for the fist time.
PS C:\Users\sjfke> start http://localhost:8480/bookstore/This project is an early stage of development and is restricted to:
Windows 11 (home)butLinuxapproach is planneddockeranddocker compose, although apodmanapproach is plannedmaven, although agradleis planned.