Configuring Tomcat Server

How to configure a Tomcat Server for JSP web application?


Configuring Tomcat Server:
A web application is executed using a WAR file or from a root directory with unpacked contents of a webapplication. Usually all this context information is contained in a "context.xml" file contained inside the "conf" folder.

Example :

<Context path="/" reloadable="false" docBase="test/" />

In the above example the "Context path" is a unique path that is the default application. The docBase or Context Root specify the absolute path of the root directory "test", it can also have "WAR" file. If the attribute "reloadable" is set to "true" then it will make catalina to check the "WEB-INF" folders like "class", "lib" for changes. If a change is detected the web application is restarted. This has some issues with some web applications as it takes some time to load so that the default value is "false".

How set the Heap Size for Tomcat:

Heap size is the memory that is allocated by the Java Virtual Machine or JVM.It is set by using two parameters Xms and Xmx of JVM.
  • Stop the Tomcat server
  • Set the Environment variable CATILINA_OPTS as below
  • set CATALINA_OPTS="-Xms512m -Xmx512m"
  • This is done in catalina.bat or files.

The maximum size for the heap memory is "1024m" which is 1GB.

How to Restart an Application in Tomcat:

An application alone can be restarted by following the below instructions.
  • Open the url "http://localhost:8080/manager/html"
  • Type in the admin "username,password"
  • Now all the applications will be listed
  • Click the "reload" link to reload a specific application

Ask Questions

Ask Question