Full HTTP2 support is added to the latest version of Tomcat 9.x. HTTP/2 is fast, much faster than HTTP/1.1. If you directly serve the content to the browser (without going through a web server) from Tomcat then implementing HTTP/2 can drastically reduce the application load time and overall improve the performance. Its recommended testing this in a non-production environment to ensure application behave as expected. Read this if you are looking to enable in a web server like Apache or Nginx.

Pre-requisite

Tomcat must be secured with SSL/TLS certificate before implementing HTTP2. If you need help with the implementation, then check out this guide.

Implementing HTTP/2 on Tomcat

Note: Take a backup of configuration files before modification so you can restore if something goes wrong.

Login to Tomcat Server and go the installation folder Go to conf folder Modify server.xml file using vi or your favorite editor Add the following in SSL connector

Overall, it should look like below. Above are my lab configuration so if you are copying it then don’t forget to adjust the configuration to fit your environment requirement — especially the port if using a custom one and certificate path.

Restart Tomcat instance by going to bin folder and execute the following scripts

Check the catalina.out log, and you should see the following confirmation that is configured to support h2

This means Tomcat is ready to serve requests over HTTP2 protocol.

Testing if Tomcat is serving over H2

How do you know if it is working as expected? There are multiple ways to test this.

Using Chrome

Useful for testing Intranet applications.

Launch Google Chrome Open Developer Tools by pressing F12 Go to the network tab Access your Tomcat application and pay attention to Protocol column

And, as you can see the requests were served using h2.

Using Logs

Look at access.log file and review the incoming requests. Do you see HTTP/2.0 is being categorized in every request?

Using Internet-based tools

If your Tomcat application URL is available on the Internet, then you can check against the following tools.

Geekflare HTTP/2 Test HTTP2.Pro

Conclusion

Implementing H2 on Tomcat is straightforward. I would strongly recommend testing your application post implementation to ensure there are no side-effects. If you are interested in learning Tomcat administration, then check out this online course.

How to Implement HTTP2 in Tomcat  - 62How to Implement HTTP2 in Tomcat  - 69How to Implement HTTP2 in Tomcat  - 15How to Implement HTTP2 in Tomcat  - 80How to Implement HTTP2 in Tomcat  - 8How to Implement HTTP2 in Tomcat  - 62How to Implement HTTP2 in Tomcat  - 16How to Implement HTTP2 in Tomcat  - 59How to Implement HTTP2 in Tomcat  - 69How to Implement HTTP2 in Tomcat  - 89How to Implement HTTP2 in Tomcat  - 65How to Implement HTTP2 in Tomcat  - 79How to Implement HTTP2 in Tomcat  - 93How to Implement HTTP2 in Tomcat  - 64How to Implement HTTP2 in Tomcat  - 32How to Implement HTTP2 in Tomcat  - 31How to Implement HTTP2 in Tomcat  - 20How to Implement HTTP2 in Tomcat  - 3How to Implement HTTP2 in Tomcat  - 23How to Implement HTTP2 in Tomcat  - 66How to Implement HTTP2 in Tomcat  - 49How to Implement HTTP2 in Tomcat  - 74How to Implement HTTP2 in Tomcat  - 62How to Implement HTTP2 in Tomcat  - 80