Getting Started With Apache Tomcat 7

By Juliet Kemp (Send Email)
Posted Oct 7, 2010

More on Apache server

Apache Tomcat is open source software that implements Java Servlet and JavaServer Pages, enabling sites to run Java servlets (like server-side applets) and Java-based dynamic content. The last major release (6.0) was in December 2006, with the most recent stable version (6.0.29) coming out last July. Version 7.0.2, which supports Servlet 3.0, JSP 2.2, and EL 2.2, has been available in beta for a couple of months.

Apache Tomcat is open source software that implements Java Servlet and JavaServer Pages, enabling sites to run Java servlets and Java-based dynamic content. Version 7.0.2 is in a mature beta, but is it data center ready?

Note that 7.0.2 is still in beta, so it's not a good match for production sites just yet. The Apache Group has specifically recommended against using it for business purposes right now; the changes are large enough that they want some real-world testing before it's released as production code. However, it's well worth installing on a non-production server to test it out. Note also that if you want to use Servlet 3.0 or JSP 2.2 apps, this is your only Tomcat option.

As well as the support for Servlet 3.0, JSP 2.2 and EL 2.2, there are various other improvements, including support for aliases, memory leak protection, and a cross-site forgery prevention filter. The provision of aliases means you can now have server-wide .war files or static content directories that you can share among applications. You no longer need to wrap them up in each app archive. This is particularly useful for common images, error redirects or other similar pages. The memory leak prevention, which has been backported to Tomcat 6 already, is neat.

Installing Tomcat

To try out 7.0.2, you'll need to download it from the web site, since, being in beta, it's not yet available as a package for Debian or Ubuntu. Both source code and binary versions are available to download. Note that the setup instructions on the web site apply only to the source code version; for the binary version, you should just be able to run bin/ from the Tomcat download directory (you may wish to move this somewhere else before running it). That's it -- your Tomcat daemon is now running. Having wrangled a very nasty install of another piece of software this week, I was incredibly impressed by how straightforward this was.

Using Tomcat

Installing a webapp is remarkably straightforward once you have Tomcat running, as demonstrated by the sample app available as part of the 'First Webapp' section of the docs. This also covers the basics of constructing your own webapps. Move the sample app into the webapps directory of your Tomcat install, and check out http://localhost:8080/sample/. Additional examples are available.

There's an access.log set up now by default (this was always available as a configuration option), which looks like the Apache Web Server access log and logs all Tomcat app accesses. This is useful for keeping track of usage and for bug-fixing.

Configuring Tomcat

The config is all done in XML files in the conf subdirectory. It's all well-documented, and most config changes should be straightforward. One particularly nice change in Tomcat 7 is in the tomcat-users.xml file. This now provides separate manager roles for the GUI, scripting, the jmxproxy, and the Status link only. Similarly, the admin role has been separated out as well. This allows for more fine-grained access control to admin and management tasks.

To use the GUI web console, edit conf/tomcat-users.xml to add these lines:

<role rolename="manager-gui" />
<user username="tomcat" password="mypasswordhere" roles="manager-gui"/>

Restart Tomcat (using the shutdown/startup scripts in the bin/ directory), then go to http://localhost:8080/manager/html and enter the username and password. Helpfully, if you don't have a username/password set up, you'll be served a page telling you how to fix the problem.

The management GUI allows you to check the server status, deploy or undeploy the various apps that are running, and run full diagnostics (not a great idea on a production server as it's load-intensive).


A few things are still missing from this release, most notably the lack of support for HTML5 WebSockets. The documentation continues to be comprehensive and readable – no big surprise from Apache, which has long been good at this. Install is similarly incredibly straightforward, as is deployment of webapps. The whole process is incredibly smooth.

The support for Servlet 3.0 and JSP 2.2 is the big change. Alias support will be extremely helpful and has long been on the wishlist. The separation of management tasks is pleasing and a security improvement. It'll be interesting to see how 7.0 does shake down in the real world; hopefully the Apache Group team will be able to fix the bugs that crop up and get a production-ready version out of the door soon.

Juliet Kemp has been messing around with Linux systems, for financial reward and otherwise, for about a decade. She is also the author of "Linux System Administration Recipes: A Problem-Solution Approach" (Apress, 2009).

Follow ServerWatch on Twitter

Page 1 of 1

Comment and Contribute

Your name/nickname

Your email

(Maximum characters: 1200). You have characters left.