java - 站点被 ping 后如何运行方法?
问题描述
我有一个 servlet 需要在站点被 ping 后运行一个方法。
My servlet:
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.myMethod();
}
它需要myMethod()
在站点被 ping 通后运行。如何实施?
解决方案
You said:
after the site has been pinged.
"ping 127.0. 0.1."
Incorrect, your web site is not being pinged. The host computer (OS) is being pinged.
The ping utility tool present in most operating systems makes a brief connection to your host computer, but not to your web server. So no Servlet will be invoked.
Therefore you cannot run code within your Servlet container in response to a ping
connection.
推荐阅读
- c# - UDP 客户端接收仅在使用本地发送方时工作
- r - 使用 R 处理图像数据
- python - 为什么代码在终端中不显示 False?
- continuous-integration - 如何通过在磁盘上创建报告文件来生成 github 注释?
- data-structures - 表面网格三角形:查询空间内
- c# - 分页在 asp 中继器中无法正常工作
- python-3.x - 在 python 3 中优化字典键生成/查找
- javascript - 动态导入中的字符 *
- python - (Mac OSX Catalina) 为什么我不能单击 Tkinter 中的按钮并使其变为蓝色?
- java - 为什么 Java 8 和 Java 11 之间已解决的依赖关系不同?