Question: How to do a http redirect to https in Sun Application Server / Web Server?

Answer: 
The servlet container should automatically redirect the user to the HTTPS listener if you set the `transport-guarantee` element to `CONFIDENTIAL` or `INTEGRAL` in your `web.xml`, like so:

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

```

The `url-pattern` element contents should match the path you wish to secure. So, for example, if you want to secure everything under `/admin`, specify `/admin/*` as your `url-pattern`. This should exhibit the following behaviour:

```
http://www.example.org/admin/login

```

will redirect to

```
https://www.example.org/admin/login

```

For more information, check out the Servlet 2.5 specification ([JSR 154](http://jcp.org/en/jsr/detail?id=154)).
One possible approach might be to use mod\_rewrite

I'm sure there's others.