Redirect from HTTP to HTTPS on Glassfish

This tutorial is intended to show you how you can force various url patterns to use HTTPS if a user tries to use HTTP.


  • Glassfish 4.1
  • Netbeans 8.1 (Not necessary, will have instruction for both)
  • JavaEE 7 (Don’t think its necessary)

Navigate to your Web Application Archive’s (WAR’s) web.xml file.

Method 1: Netbeans

NB Step 1

NB Step 2

Method 2: Good ol’ Copy n’ Paste

The above steps would have created the following code which you would add into your file. I apologize it would not save the spaces.


<description>This will make the constraint affect all pages of the application</description>