JAVA

[Java] Java에서 http와 https 프로토콜 구분하는 방법

망뎅이 2014. 3. 6. 17:18
반응형

httphttps 프로토콜을 구분하기 위해 HttpServletRequest 객체의 getprotocol() 객체를 생각하시는 분들이 있을겁니다. 하지만, getProtocol() 객체로는 https 프로토콜 여부를 http 프로토콜과 같은 객체인  HTTP/1.1로 리턴하게 됩니다. 아래는 Jave EE 문서 API 입니다.

getProtocol

String getProtocol()
Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1. For HTTP servlets, the value returned is the same as the value of the CGI variable SERVER_PROTOCOL.

Returns:
String containing the protocol name and version number

https 프로토콜을 구분하기 위해 isSecure() 메소드를 이용할 수 있습니다.

isSecure

boolean isSecure()
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.

Returns:
a boolean indicating if the request was made using a secure channel


반응형