Tomcat Introduction and Purpose of Different Folders
If you are planning to develop web application in Java. The Java EE technology used to develop web applications is Servlets. Servlets are java classes that process the web requests and deliver response to browser. Putting these classes directly in just JVM is not possible, nor it would start processing web requests. We need some server to receive the HTTP requests (HTTP is the protocol the browser and server talks in), convert it into an object oriented representation (from stream of bytes written on server socket into objects understandable by our java classes i.e. Servlet) and pass the request to our servlets. So that we don't have to deal with lower level details of network programming like programming HTTP protocol to receive the requests and sending response to user browser. But we could focus on building business logic of our projects.
Tomcat is a server that receive web requests over the network, converts them into refined object oriented representation and dispatch the request processing to servlets that we program. As the Tomcat start and invoke the Servlets on requests, its also called Servlet Container. Tomcat runs the servlets by invoking their life cylce methods e.g. when to start the servlet, how to process requests, and when to destroy the servlet object. Tomcat is written in Java and executes java classes, so we need JVM to run it.
Tomcat is fundamentally a Servlet Container but it comes with a built-in Web Server (called Coyote). Tomcat is used in two ways. 1) As Web Server and Servlet Container combined. 2) Only as a Servlet Container. In 2nd case, we install a web server, for example Apache Web Server or Microsoft IIS, to receives the web requests over the network and configure it to pass specific URLs to Tomcat. These URLs identify some servlet to be invoked to serve the requests.
<todo: Click Here to read more about Serlvets>
Tomcat
Tomcat is a server that receive web requests over the network, converts them into refined object oriented representation and dispatch the request processing to servlets that we program. As the Tomcat start and invoke the Servlets on requests, its also called Servlet Container. Tomcat runs the servlets by invoking their life cylce methods e.g. when to start the servlet, how to process requests, and when to destroy the servlet object. Tomcat is written in Java and executes java classes, so we need JVM to run it.
Tomcat is fundamentally a Servlet Container but it comes with a built-in Web Server (called Coyote). Tomcat is used in two ways. 1) As Web Server and Servlet Container combined. 2) Only as a Servlet Container. In 2nd case, we install a web server, for example Apache Web Server or Microsoft IIS, to receives the web requests over the network and configure it to pass specific URLs to Tomcat. These URLs identify some servlet to be invoked to serve the requests.
<todo: Click Here to read more about Serlvets>
Tomcat Installation
Tomcat is very easy to install. All you need is to download its zip file and decompress in a folder on your computer. Your Tomcat is installed and ready to receive web requests. Visit: http://tomcat.apache.org/ and choose a version number on left side, you are interested to download.
Purpose of Different Folders of Tomcat
For example, after you download Tomcat 8 and unzip the file. The contents of the folder would look like this:
- bin
It contains different executable files to start or stop the server. to run as a service, etc. startup.bat (on Windows) and startup.sh (on Linux) is very commonly used to start the Tomcat. - conf
conf is short for "configuration" files. So the conf folder contains different files to configure different features or details of the server or the apps it host. for example, running tomcat on different port, configuring HTTP, configuring domains and sub domains, etc. - lib
Many Java classes, interfaces, enums, and exceptions which are commonly used to run web applications are placed in this folder as Java Archive files (.jar) for example, the servlet API and JSP API. Classes that implements Tomcat's own functionality are also placed in this folder. - logs
When we wite web applications, we print different log messages. Tomcat and other libraries used in the project also print the status messages which are used to diagnose problems or see the current activity performed by the server. The logs folder contains all logs files. - temp
The tomcat use this folder to place temporary files when processing the requests. For example, when user upload a file on form, tomcat automatically place the submitted file in temp folder during the request processing, from where programmer shift the file to some permanent location. These files are generally removed by Tomcat itself, but if there is some bug in your application, the file may persist for long and would fill to much storage very soon. So keep an eye on it. And its MOSTLY safe to remove the contents of this folder after you stop the Tomcat properly. - webapps
Its the most important folder for a web developer. As it contains the web applications Tomcat deployes. Generally the web application is placed as Java Web ARchive files (.WAR). When tomcat is run, it automatically detects the web apps placed in this folder and deploys it. There are other means to deploy the web apps too, that I would discuss in some other post. - work
Tomcat stores compiles JSP and other resources from webapps folder into it. and the files tomcat need at runtime are also placed into it. Its something like cache for the Tomcat to put different components.
Comments
Post a Comment