我是Java新手,使用Tomcat。在Https和Http中打開Jsp頁面
我已經配置Tomcat來使用這個鏈接 source
我只是做了更改server.xml文件在Tomcat中directory.And變化看起來是這樣的HTTPS運行。
<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
keystoreFile="C:\Users\sanjithkumar017\Desktop\myKey.keystore" keystorePass="qwerty"
clientAuth="false" sslProtocol="TLS" />
然後我能夠成功訪問網址https://localhost:8443
。
我創建了我的項目的戰爭文件(mserv),並將它放在tomcat的webapps文件夾中。
問題是,當我打它的網址https://localhost:8443/mserv/dis.jsp
我得到的答覆(我的意思是有效的)。而且當我嘗試http://localhost:8080/mserv/dis.jsp
它工作正常。
這應該是這樣工作的。我希望jsp頁面只能在https上運行。
接下來我做了什麼是添加一個web.xml文件到我的eclipse項目(因爲我需要在我的項目中運行一些jsp頁面http)。web.xml文件看起來像這樣。
<security-constraint>
<web-resource-collection>
<web-resource-name>secured page</web-resource-name>
<url-pattern>/mserv/dis.jsp</url-pattern>
<url-pattern>/mserv/index.jsp</url-pattern>
<url-pattern>/mserv/pcr.jsp</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
那麼我現在期待的是,只有上述(應用程序的web.xml)中提到的網頁必須是可訪問的https.But的是,我能夠通過訪問所有的頁面都HTTP和https。
我希望僅使用https訪問我的頁面。
我在哪裏錯了,請幫忙。
JDK :: jdk1.7.0_79
的tomcat :: Apache的Tomcat的7.0.67
你需要編寫自定義Servlet過濾器或Tomcat閥。我會看看我以後是否可以發佈一些代碼。 –
哦,是的,請.. –