I have a java web application with embedded tomcat version 6.0.37 and I am using http as well as https. I have a configuration page where I have options:
1. SSL enable
2. SSL redirect
3. SSL Port
4. HTTP Port
SSL is enabled by default. I want to redirect every http request to https. So, on configuration page, I check SSL redirect option, checks Restart option and submits my form.
On server side, I am doing following:
I want to just restart the connector instead of restarting the whole container and letting my whole application down.
Changing other options(HTTP port, SSL port, SSL enabled), connector is restarted and works fine, but enabling SSL redirect isn't working. SSL redirect works after I restart my application.
I have searched a lot, but I am unable to resolve this issue. Will appreciate any help.
You can make code samples a lot easier to read if you wrap it using the tags that our message editor creates when you click the "Code" button.
Rather than coding this kind of stuff in your webapp, your almost certainly should be doing it by setting the transport guarantee in WEB-INF/web.xml.
An IDE is no substitute for an Intelligent Developer.
Joined: Dec 16, 2013
Tim Holloway wrote:You can make code samples a lot easier to read if you wrap it using the tags that our message editor creates when you click the "Code" button.
Next time onward, I will follow that.
Tim Holloway wrote:Rather than coding this kind of stuff in your webapp, your almost certainly should be doing it by setting the transport guarantee in WEB-INF/web.xml.
I am using embedded tomcat and I have to set all the configurations programmatically. I have a configuration page in my application which lets me do that. So, when I enable SSL redirect from my configurations page, the security constraints are added to the context, when I disable it, it's removed from context. Issue is that, it doesn't comes into effect until I restart my application.
As suggested on http://tomcat.apache.org/tomcat-6.0-doc/api/org/apache/catalina/startup/Embedded.html I destroyed my context, recreated it with adding constraint, and re-added it to host, this solves my problem but there's a log message appearing:
SEVERE: The web application  appears to have started a thread named [http-8080-Acceptor-0] but has failed to stop it. This is very likely to create a memory leak.