读取超文本传输​​协议(HTTP或HTTPS)

Som*_*Guy 0 url https http

我想阅读用户所在的协议.HTTP或HTTPS并相应地在该页面上为站点2构建我的URL.

第1步: Read the url user is on site 1 //可以是http或https

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

FF处理得很好.但IE不允许从HTTPS站点导航到HTTP站点.

   <a href="protocol://site2.com/">Click here for site 2</a>
Run Code Online (Sandbox Code Playgroud)

小智 6

从我的jsp,我能够将URL分成几部分.例如,https://test.com:8080/会产生:

request.getScheme() = https
request.getServerName() = test.com
request.getServerPort() = 443
Run Code Online (Sandbox Code Playgroud)

请参阅此文档了解详细信息