从 http 到 https
我有一个简单的 Web 应用程序:一个带有要提交的表单的网页,以及服务器端的 servlet。
有用。
我现在被要求更改它,以便表单的地址更改为
http://www.example.com/myForm.html 到 https://www.example.com/myForm.html
执行此操作的步骤是什么?我必须更改我的 servlet 吗?我的部署?我的网页? 他们全部?
谢谢。
I have a simple web app: a web page with a form to submit, and a servlet on the server side.
It works.
I am now asked to change it so that the address of the form changes from
http://www.example.com/myForm.html to https://www.example.com/myForm.html
What are the steps to do this? Do I have to change my servlet? My deployment? My web page?
All of them?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
只是您的部署,而不是您的 servlet。问题在于将 Web 服务器配置为使用 HTTPS(基于 SSL 的 HTTP)而不是 HTTP(明文 HTTP)来提供页面服务。
如果您的 servlet 没有到自身的绝对(而不是相对)链接,那么该配置更改应该不会对您的 servlet 产生任何影响,但无论如何您都不会这样做。 :-)
有关 HTTPS 的更多信息请参见此处。 配置的详细信息将取决于您的 Web 服务器正在使用。
Just your deployment, not your servlet. It's a matter of configuring your web server to use HTTPS (HTTP over SSL) rather than HTTP (cleartext HTTP) to serve the page.
That configuration change should have no effect on your servlet whatsoever, provided your servlet doesn't have absolute (rather than relative) links to itself, but you wouldn't do that anyway. :-)
More about HTTPS here. The details of the configuration will depend on the web server you're using.
servlet 容器必须配置为传送加密的内容。以下是如何在 Tomcat 上执行此操作。如果您使用其他 servlet 容器,请将该信息添加到您的问题中。
The servlet container has to be configured to deliver the contents encrypted. Here is how to to do that on Tomcat. If you use another servlet container please add that information to your question.
)<Connector>
)这只是客户端和服务器通过网络相互通信的方式的改变。这是服务器配置的问题。只需将服务器配置为使用 HTTPS 即可。无需更改代码逻辑/流程,您只需相应更新 Web 应用程序中任何引用的绝对 URL(在 HTML 链接、表单操作等中)。因此,如果您的表单操作是
http://www.example.com/myForm.html
而不是myForm.html
并且当前打开的页面不是通过 HTTPS 打开的,那么您需要将表单操作更改为HTTPS URL。至于服务器配置,尚不清楚您使用的是什么服务器,因此这里有一个针对 Tomcat 的示例,说明如何配置服务器以使用 HTTPS (SSL): http://tomcat.apache.org/tomcat-6.0-doc/ssl-howto.html。任何有自尊的服务器都会附带此信息。
It's just a change in the way how the client and the server communicate over network with each other. This is a matter of server configuration. Just configure the server to use HTTPS instead. No changes in the code logic/flow are necessary, you only need to update any referenced absolute URL's in your webapp accordingly (in HTML links, form actions, etc). So if your form action is for example
http://www.example.com/myForm.html
instead ofmyForm.html
and the currently opened page is not opened by HTTPS, then you need to change the form action to the HTTPS URL.As to the server configuration, it's unclear what server you're using, so here's a Tomcat-targeted example how to configure the server to use HTTPS (SSL): http://tomcat.apache.org/tomcat-6.0-doc/ssl-howto.html. Any self-respected server ships with this information.