Apache Tomcat - Tutorial: Lars Vogel
Apache Tomcat - Tutorial: Lars Vogel
Apache Tomcat - Tutorial: Lars Vogel
Lars Vogel
Version 0.5 Copyright 2008 - 2010 Lars Vogel 03.08.2010 Revision History Revision 0.1 Created Revision 0.2-0.5 bug fixed and enhancements Apache Tomcat This article describes the installation and usage of Apache Tomcat for Java web development. Tomcat version 6.x is used in this tutorial. 09.04.2009 - 03.08.2010 Lars Vogel 18.11.2008 Lars Vogel
Table of Contents 1. Apache Tomcat 2. Installation 2.1. Windows 2.2. Ubuntu Linux 2.3. Admin user 3. Managing Apache Tomcat 3.1. Start Tomcat on Windows 3.2. Start Tomcat on Ubuntu (Linux) 3.3. Test Tomcat 3.4. Deployment 4. Security Manager 5. Developing Java web applications 6. Tomcat as HTTP Server 7. Thank you 8. Questions and Discussion 9. Links and Literature 9.1. Apache Tomcat
1. Apache Tomcat
Apache Tomcat is a webcontainer which allows to run servlet and JavaServer Pages based web applications. Most of the modern Java web frameworks are based on servlets and JavaServer Pages and can run on Apache Tomcat, e.g. JavaServer Faces, Struts, Spring. Apache Tomcat also provides per default a HTTP connector on port 8080, e.g. Tomcat can also be used as HTTP server even though the performance of Tomcat is not as good as the performance of the Apache HTTP server.
2. Installation
2.1. Windows
Download the Windows installer for Tomcat6 from Apache Tomcat Homepage and run the installer. The installation directory of Tomcat looks like the following:
The default user under windows for tomcat is "admin" with the password "admin". The maintained users can be found in the tomcat installation directory /conf/tomcat-users.xml On Ubuntu the admin user is usually not created automatically, you have to add the user entry manually to /etc/tomcat6/tomcat-users.xml. Check http://localhost:8080/manager/html for the required user in the error message.
To start Tomcat directly press the button "Start". Tomcat can get configured to started automatically via the "Automatic" selection in the drop-down "Startup type".
3.4. Deployment
The standard deployment format for webapplications is .war. If you have create a war application just put this application into the "webapps" folder. The next time tomcat starts it will unpack the war and make the application available. Web applications may require external libraries.Typically web application contain there own libraries but if you want to make certain libraries avaiable for all applications you can put them
into the folder "lib" and a subfolder below "lib". These libraries are then available for all web applications.
4. Security Manager
Tomcat uses the same security model as Java. The default security manager configured in Tomcat will for example prevent the webapplication to write to the file system. This security manager is configured in the catalina.policy file in the conf directory. For details on the manager see http://tomcat.apache.org/tomcat-6.0-doc/security-managerhowto.html . If you want for example to grand the webapplication "performance" access to all files in the server directory c:\temp\wstest then add the following entry to "catalina.policy".
grant codeBase "file:${catalina.home}/webapps/performance/-" java.io.FilePermission "c:\temp\wstest\<<ALL FILES>>", "read,write,execute,delete"; }; {
Tip
To allow directory browsing via Apache Tomcat change the parameter "listings" in the file conf/web.xml from false to true.
<servlet> <servlet-name>default</servlet-name> <servlet-class>org.apache.catalina.servlets.DefaultServlet</servletclass> <init-param> <param-name>debug</param-name> <param-value>0</param-value> </init-param> <init-param> <param-name>listings</param-name> <param-value>true</param-value>
7. Thank you
Please help me to support this article: