你如何通过https启动java servlet? [英] How do you start a java servlet over https?
问题描述
我正试图在eclipse中运行tomcat上的servlet。当我在服务器上运行时,servlet运行并为我提供如下链接:
I am trying to run a servlet on tomcat in eclipse. When i do run on server, the servlet runs and provides me with a link like follows:
http:// localhost:8443 / AuthServer / Server
"http://localhost:8443/AuthServer/Server"
我已经为SSL配置了我的Tomcat服务器,如下所示:
I have configured my Tomcat server for SSL as follows:
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" keystoreFile="C:\Users\owner\.keystore" keystorePass="sheetalkshirsagar">
当我在服务器上运行servlet时,它仍然使用http。
我希望我的servlet链接是https:// ...而不是http:// ..。你是怎么做到的?
When I run the servlet on server it still uses http. I want my link to the servlet to be "https://..." instead of "http://..". How do you do that?
推荐答案
如果你想确保在向该servlet发送请求时使用https协议你需要更改Web应用程序中的 WEB-INF / web.xml
文件。
在您的情况下添加此配置参数:
If you want to be sure to use the https protocol when you send request to that servlet you need to change the WEB-INF/web.xml
file in your web application.
In your case add this configuration params:
<security-constraint>
<web-resource-collection>
<web-resource-name>AuthServer</web-resource-name>
<url-pattern>/Server</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
这篇关于你如何通过https启动java servlet?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!