Tomcat Installation Directory is a directory or folder where the tomcat server was installed i.e. <Tomcat_home>. In the tomcat server, we discussed what tomcat is, how to install it, how to change the port number, username, and password. At installation time we installed tomcat at D:\Installed\Web Servers\Tomcat10 which will be called the tomcat installation directory or <Tomcat_home>.
Note:- After installation of the tomcat server we can’t change the installation directory, and in order to do that we must reinstall the tomcat server.
Tomcat Installation Directory Structure
The <Tomcat_home> contains the following important folders and files,
|bin||*.exe, *.bat files|
|webapps||Deployed web applications|
|log||Generated log files|
The bin folder contains *.exe files, *.bat files. Among them, the tomcat10.exe is the most important file for us which is used to start and stop the tomcat web server. The *.bat files contain the logic and they are called and executed through the tomcat10.exe file. It also contains bootstrap.jar and tomcat-juli.jar files. The bootstrap.jar contains classes to bootstrap the tomcat server, and tomcat-juli.jar to manage log messages.
The conf contains configuration, *.xml files. Some of the regularly used files are:- server.xml, tomcat-users.xml, context.xml. The server.xml is used to modify the server configuration like a port number. The tomcat-users.xml file is used to add/modify/update admin details like username, password, and their role. Similarly, the context.xml file is used to modify the monitoring resources.
The lib folder contains all the library files in the form of JAR files which are required for tomcat server execution. Examples of some files:- serverlet-api.jar, jsp-api.jar, jaspar.jar, catalina.jar, and e.t.c. The catalina.jar represents the servlet container and jaspar.jar represents the JSP container. The serverlet-api.jar and jsp-api.jar represent the original servlet and JSP technology API respectively.
Tomcat server comes with a built-in servlet container and JSP container. The serverlet-api.jar and jsp-api.jar are the main JAR files, and others are the supporting JAR files.
|serverlet-api.jar||Servlet technology API|
|jsp-api.jar||JSP technology API|
In the execution of basic Java applications with the main method, JDK APIs are required (java.lang, java.util, and e.t.c. are the part of that). Similarly, to execute servlet code Servlet API, and to execute JSP code both Servlet and JSP API are required.
- Servlet API old package names:- javax.servlet, javax.servlet.http, javax.servlet.annotation, and e.t.c.
- JSP API old package names:- javax.servlet.jsp, javax.servlet.jsp.el, javax.servlet.jsp.tagext
After changing the JEE module names the servlet API package names also changed.
- Servlet API new package names:- jakarta.servlet, jakarta.servlet.http, jakarta.servlet.annotation, and e.t.c.
- JSP API new package names:- jakarta.servlet.jsp, jakarta.servlet.jsp.el, jakarta.servlet.jsp.tagext
Every Servlet component (web component) is a Java class that is developed by using Servlet API. So, before compiling that Java class we must add <Tomcat_home>\lib\servlet-api.jar file to the classpath.
The webapps folder will contain all the deployed web applications. After developing the web applications having web components, we deploy them in the tomcat server by copying them to this folder either in the form of directories or in the form of the WAR file. WAR means Web Application Archive, a kind of JAR file.
The webapps folder comes with some predefined example web applications like- ROOT, examples, docs, manager, and e.t.c. directories. After opening the tomcat server home page in the browser we are getting a welcome screen, it is because of the ROOT example which contains all the logics. If you open the index.jsp file of ROOT in any text editor then you can find the text “<h2>If you’re seeing this, you’ve successfully installed Tomcat. Congratulations!</h2>” which we were getting on the welcome screen.
Other Files and Folders
- logs:- All the generated log files will be stored here in the form of *.log and *.txt file. Every day new log files will be generated.
- temp:- It will contain all the temporary files.
- work:- It contains a Catalina folder, and that contains the servlet container internal folder.
- Apart from the above files, it also contains some other files in the Tomcat installation directory.
If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or do you find anything incorrect? Let us know in the comments. Thank you!