0

How to check the URL is http or https through programmatically using HttpServlet. If the Url is http send message as Warning otherwise message as Allow.

How to prevent HTTP Url and allow HTTPS through programmatically.

1 Answer 1

1

You can detect HTTPS inside a servlet via servletRequest.isSecure().

To force use of HTTPS, just configure secure Urls in your web.xml. The when users go to HTTP they will be redirected to HTTPS.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks. In the configure secure Urls can be redirect from other protocols to https. My question is how to prevent other protocols. When we have use https allow the web page, otherwise block/prevent Other protocols.
For example when users use this URL http://appengine.google.com in this URl is automatically redirect to https://appengine.google.com. I don't like this mechanism. For example I need when users use this sample URL http://appengine.google.com browsers redirect to 404 or 505 or any Error Message. Is it possible?
Only with custom Servlet Filter: oracle.com/technetwork/java/filters-137243.html
Thanks. Any other solution to prevent http without filter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.