Question: 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: 
You can't reliably depend on port numbers.  

But you can depend on the scheme: 

Use: [request.getScheme()](http://download.oracle.com/javaee/1.2.1/api/javax/servlet/ServletRequest.html#getScheme%28%29) to see if it is `https`. 

If it is then it is secure connection. 

I believe this should work regardless of Tomcat version
[isSecure](http://tomcat.apache.org/tomcat-7.0-doc/servletapi/javax/servlet/ServletRequest.html#isSecure%28%29). Be sure to check the inherited methods.