Navigation

Tomcat

Prerequisite, before we dwell in tomcat one should clear the below concept.related to JRE and JDK,JDK ( Java development Tool Kit) it comes with Java libraries which are used/referenced by software develpers in their code. The code is then compiled

using the javac utility in the JDK, once compiled the code the javac creates

class files, The class files are then executed by JVM of the JRE.

JRE (Java Runtime Environment) : Contains the JVM (Java Virtual Machine),class libraries. It does not contain any development tools.Its job is to run programs i.e class files created by the above said JDK.

Tomcat is an application server developed by Apache Software Foundation. It is used to run the JSP and Java servlets.

Installation :

You could download the installer from here.After the download install it, make sure you have installed the JRE on your system.You could download the jre from here

While installation it would ask for the admin password for tomcat manager, using whichyou could easily deploy your application.

After installed you have the following directory structure is created in the installed directory

bin : Contains the scripts for Startup and shutdown of the tomcat server

conf : Contains the various configuration files Server.xml = Main configuration file of the tomcat server web.xml = This sets the default values for the various webapps deployed in the tomcat server

3) Our code is now created, but now we have to create a application i.e we have the package itas war file so that it could be deployed to the application server. For that create following directory structure

5) Login to the administration deploy and deploy the war file, as for tomcat go to the tomcat management console i.e at http://<host>:8080 in the select war file field select our newly created war file and deploy it.

6) Thats it ! war file deployed we could acces our servlet at the urll http://<host>:8080/hello/hello

In the background

The file web.xml has the description of the what are the contents of the deployment application<servlet-name> tag gives a identity to the class file inside the applicatoinand in the <servlet-mapping> maps the class through name to the url i.e http://<host>:8080/<app-name>/<url-pattern>and the class file is execute to produce the html which is send to the requesting browser

Again for the jsp , the above routine is followed, first the java file is created which is compiled to produce class filewhich is then executed to produce the html file copy of which is then to the requesting browser.