8.6. Example: Programmatic Security and SSL

Listing 8.5 presents a servlet that redirects non-SSL requests to a URL that is identical to the URL of the original request except that http is changed to https. When an SSL request is received, the servlet presents a page that displays information on the URL, query data, key size, encryption algorithm, and client certificate. Figures 8-7 and 8-8 show the results.

Figure 8-7. New-certificate page for Internet Explorer. View and import the certificate to suppress future warnings. For details on creating self-signed certificates for use with Tomcat, see Section 7.5. Again, self-signed certificates would not be trusted in real-world applications; they are for testing purposes only.

Figure 8-8. Result ...

Get More Servlets and JavaServer Pages™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.