How can I know if the request to the servlet was executed using HTTP or HTTPS?

ufk picture ufk · Nov 20, 2011 · Viewed 48.5k times · Source

I wrote a servlet in Java and I would like to know if the request to that servlet was executed using HTTP or HTTPS.

I thought I can use request.getProtocol() but it returns HTTP/1.1 on both methods.

Any ideas?

Answer

Ramesh PVK picture Ramesh PVK · Nov 21, 2011

HttpSerlvetRequest.isSecure()