开发者

read Hypertext Transfer Protocol (HTTP or HTTPS)

开发者 https://www.devze.com 2023-03-10 17:39 出处:网络
I want to read the protocol the user is on. HTTP or HTTPS and build my url for site 2 on that page accordingly.

I want to read the protocol the user is on. HTTP or HTTPS and build my url for site 2 on that page accordingly.

Step 1: Read the url user is on site 1 //Could be anything http or https

Step 2: Prefix the protocol for site 2 on that site 1 page according. HTTP or HTTPS as per step 1

FF handles it good. But IE do开发者_JAVA百科esn't allow navigation from HTTPS site to HTTP site.

   <a href="protocol://site2.com/">Click here for site 2</a>


From my jsp, I was able to break an URL into parts. For example, https://test.com:8080/ would yield:

request.getScheme() = https
request.getServerName() = test.com
request.getServerPort() = 443

See this document for details.


What language are you trying to do it in?

For JavaScript, there's parent.location.protocol

For PHP, you can try using $_SERVER['SERVER_PORT'] == 443 or even $_SERVER['HTTPS']


I did it with String scheme = request.getScheme(); in my JSP

0

精彩评论

暂无评论...
验证码 换一张
取 消