What Is New in Apache Tomcat 7.0
Tomcat 7.0 is a major release focusing on Servlet 3.0, JSP 2.2, and EL 2.2 specification support. It introduces significant new features, performance improvements, and a host of bug fixes to modernize the container.
| Category | Key Changes |
|---|---|
| New Features | Servlet 3.0, JSP 2.2, EL 2.2 support, WebSocket protocol support, aliases for web resources |
| Improvements | Memory leak prevention, better OSGi support, enhanced Manager and Host Manager applications |
| Bug Fixes | Over 100 fixes across all areas including AJP, clustering, and session persistence |
| Security | Updates to address security vulnerabilities identified in previous versions |
| Deprecated | Legacy features from older specifications have been removed or marked for removal |
How does Servlet 3.0 change development in Tomcat 7?
Servlet 3.0 is the cornerstone of Tomcat 7. It introduces annotations for declaring servlets, filters, and listeners, which eliminates the need for a bulky web.xml file. You can now use @WebServlet, @WebFilter, and @WebListener directly in your classes.
This makes development faster and the codebase cleaner. You can also take advantage of dynamic registration and asynchronous processing, which are huge for building modern, scalable applications.
What memory leak fixes were implemented?
Tomcat 7 tackled several notorious memory leak scenarios. The container now does a much better job of cleaning up threads and class loaders when a web application is stopped or reloaded.
In practice, this means you can redeploy applications more frequently during development without slowly consuming all your JVM memory. It's a significant boost for stability in long-running production servers as well.
Is there built-in WebSocket support?
Yes, Tomcat 7.0 includes support for the WebSocket protocol (RFC 6455). This allows you to build interactive web applications that require full-duplex communication channels over a single TCP connection.
You can create WebSocket endpoints by annotating a POJO with @WebSocketEndpoint. This was a forward-looking feature that paved the way for the real-time web applications we commonly build today.
How were the management applications improved?
The Manager and Host Manager web applications got a complete overhaul. They were rewritten to provide a more modern and functional interface for managing web application deployments and virtual hosts.
The new Manager app offers better diagnostics, including the ability to detect potential memory leaks. This is your first stop for troubleshooting a running Tomcat instance.
FAQ
Can I deploy a web.xml from Tomcat 6.x without changes?
Most likely, yes. Tomcat 7 maintains backward compatibility with the Servlet 2.5 specification. Your old web.xml files will still work, but you can now modernize them by using annotations instead.
What are the most common pitfalls when upgrading to Tomcat 7?
The main issues usually involve libraries that are not compatible with Servlet 3.0. Check your dependencies, especially older JAR files that might try to manually configure the servlet context in ways that conflict with the new annotation-based approach.
Does the new EL 2.2 support offer any new syntax?
Yes, a big one. EL 2.2 allows you to invoke non-getter methods directly within your JSP pages. For example, you can now write ${myBean.doSomething()} instead of having to create a separate getter method.
Is the new WebSocket implementation production-ready?
For its time, yes. However, this was the initial implementation. For mission-critical applications, many developers eventually moved to the more mature and feature-complete WebSocket support provided in later Tomcat versions (8 and 9).
How does the memory leak prevention work?
Tomcat 7 introduced more aggressive cleanup routines when an application is undeployed. It identifies and clears references held by the container, such as thread locals and scheduled tasks, that previously prevented the application's classloader from being garbage collected.