Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I understand that URL patterns can be used to have some handled under HTTP and others under HTTPS.

Let's imagine a web application with two servlets, each accessed with different URL patters (for example .../myapp/servlet1 and .../myapp/servlet2), how can I have to first one handled by HTTP and the second with HTTPS?

Can you provide a configuration example?


share|improve this question
Do you use Apache HTTP Server or other HTTP server as frontend? – alvosu Jan 30 '11 at 16:34
No, but I could if necessary... – JVerstry Jan 30 '11 at 21:57
up vote 2 down vote accepted

The main idea here is that you want to specify which pages are using SSL

Using SSL in Tomcat requires 3 main step:

  1. You first need to create a SSL certificate. For instance you can use the tool provided with the JDK: keytool. For instance: keytool -genkey -alias tomcat -keyalg RSA -keystore keystore.ssl. You will be asked for a password, and once you filled all information needed, press RETURN to use the same password. Move the file created under CATALINA_HOME.
  2. You then need to enable the SSL connector in tomcat. To do so, in conf/server.xml, for instance: (SECTION 1)
  3. You need to specify in your application which URL require the usage of SSL. As an example, let's take the manager application. In WEB-INF/web.xml just before </security-constraint>, add the following: Same link as above but see SECTION 2.

I know this is very brief but that should give you a lead of what to do :)

share|improve this answer
Thanks, I am copying the content of your link here, since it has a TTL - <!-- SECTION 1: In server.xml --> <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="150" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" keystorePass="password" keystoreFile="${catalina.home}/keystore.ssl" /> <!-- SECTION 2: In WEB-INF/web.xml --> <user-data-constraint> <transport-guarantee>CONFIDENTIAL</transport-guarantee> </user-data-constraint> – JVerstry Jan 30 '11 at 21:59 is not available at this time. This answer will be helpful for me, I think. Could you please direct me rightly? – hina10531 Apr 14 '15 at 8:21

I suggest that you set up Apache as a reverse proxy and let it handle the front end. You can configure two virtual hosts (one for http and one for https) which connect to the respective Tomcat backend servlets.

You can look at this question for config examples. You want to do almost exactly the same thing.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.