File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Redirecting to HTTPS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Redirecting to HTTPS" Watch "Redirecting to HTTPS" New topic

Redirecting to HTTPS

Saikiran Kochi

Joined: Mar 25, 2008
Posts: 1

How to make secure my page by redirecting to "https" from "http" request?
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

You can do it declaratively with security-constraint entries in web.xml or
you can do it programmatically by reading the isSecure property from the request object and redirecting to the secure version of you page yourself.

Filters are a nice place to put this code.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
Welcome to JavaRanch.

Adding a security constraint like the following to your web.xml will require HTTPS for all URLs:
I agree. Here's the link:
subject: Redirecting to HTTPS
It's not a secret anymore!