Nelo Angelo
Nelo Angelo

Reputation: 1007

Redirecting to HTTPS servlets

I am trying to create an example that uses HTTPS connection. I have successfully configured a custom certificate following the steps given in Tomcat 6.0 documentation. A https://localhost:8443/ successfully opens the Tomcat index page.

I am unable to configure a page/servlet to open in HTTPS. Would anyone please suggest me the steps to configure a webapp to automatically redirect itself into a HTTPS connection.

Upvotes: 2

Views: 1296

Answers (1)

Ramesh PVK
Ramesh PVK

Reputation: 15446

Requests using HTTP (non-secure) for URLs whose transport guarantee is CONFIDENTIAL are automatically redirected to the same URL using HTTPS.

Add the following to your web.xml

<security-constraint>
    <web-resource-collection>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>

Upvotes: 2

Related Questions