Is it possible, with Tomcat, to allow ONLY secure connections (HTTPS) for a Context or a Directory?

Daniele Galluccio

For allowing only HTTPS (secure) connections, you need to activate Tomcat's the SSL support. If you need help on this, just refer to the Tomcat SSL Configuration HOW-TO documentation pages.

Then, you need to add

		<web-resource-name>Entire Application</web-resource-name>
to your web application descriptor (web.xml) and change the url-pattern to match the directory you want to access only via HTTPS.

Please, keep in mind that since the web application descriptor is an XML file, attributes definition order is important. All attributes are optional but defining them in the wrong place may prevent your application to act as you expect.