Saturday, December 26, 2020

Sample of manual build MVC Web Application for Tomcat 9.0.40

This post follows up Practice coding in Java by writing a game recently published at LXER. Focus has been done on manual invoking "javac" using standard command line options for placing in right folders packaged Java Beans and Servlets which are required by Tomcat 9 Java Web's server.  I intentionally avoid storing data in MySQL 8.0.22 database what is actually common practice, but requires the most recent updates in coding JDBC connection to database ( LTS JDK 11 ) .  Just a reminder any Java Server converts JSPs (JSFs) into system generated servlets at runtime, in particular case it is Jasper Compiler integrated into Tomcat Server.

Content of Java beans and servlets along with JSPs might be found here

Now create standard folders structure under $CATALINA_HOME/webapps and and invoke javac to create packaged classes

[tomcat@sever33fedora WEB-INF]$ ls -l
total 4
drwxr-xr-x. 3 tomcat tomcat  17 Dec 26 12:39 classes
drwxr-xr-x. 2 tomcat tomcat 103 Dec 26 12:28 src
-rw-r--r--. 1 tomcat tomcat 800 Dec 26 12:45 web.xml

[tomcat@sever33fedora WEB-INF]$ pwd

[tomcat@sever33fedora WEB-INF]$ ls -l src
total 12
-rw-r--r--. 1 tomcat tomcat 3273 Dec 26 12:26
-rw-r--r--. 1 tomcat tomcat 1092 Dec 26 12:28
-rw-r--r--. 1 tomcat tomcat  837 Dec 26 12:23

[tomcat@sever33fedora WEB-INF]$ cd classes

$ javac -cp .:$CLASSPATH ../src/ -d .
$ javac -cp .:$CLASSPATH ../src/ -d .
$ javac -cp .:$CLASSPATH ../src/ -d .

[tomcat@sever33fedora classes]$ ls -CR



GetAvailableRoomsByResidence.class  GetRoomsByResidenceServlet.class  Room.class 

$ cd ../../
[tomcat@sever33fedora Rooms]$ pwd

[tomcat@sever33fedora Rooms]$ ls -l
total 12
-rw-r--r--. 1 tomcat tomcat 1080 Dec 26 12:49 displayRooms.jsp
-rw-r--r--. 1 tomcat tomcat  192 Dec 26 12:49 noRooms.jsp
-rw-r--r--. 1 tomcat tomcat  803 Dec 26 12:50 SelectHostel.jsp
drwxr-xr-x. 4 tomcat tomcat   47 Dec 26 12:45 WEB-INF

No comments:

Post a Comment