获取 web 服务器 port
Tomcat:
public static String getServerPort(boolean secure) throws AttributeNotFoundException, InstanceNotFoundException, MBeanException, ReflectionException {
MBeanServer mBeanServer = null;
if (MBeanServerFactory.findMBeanServer(null).size() > ) {
mBeanServer = (MBeanServer)MBeanServerFactory.findMBeanServer(null).get();
}
if (mBeanServer == null) {
System.out.println("调用findMBeanServer查询到的结果为null");
return "";
}
Set<ObjectName> names = null;
try {
names = mBeanServer.queryNames(new ObjectName("Catalina:type=Connector,*"), null);
} catch (Exception e) {
return "";
}
Iterator<ObjectName> it = names.iterator();
ObjectName oname = null;
while (it.hasNext()) {
oname = (ObjectName)it.next();
String protocol = (String)mBeanServer.getAttribute(oname, "protocol");
String scheme = (String)mBeanServer.getAttribute(oname, "scheme");
Boolean secureValue = (Boolean)mBeanServer.getAttribute(oname, "secure");
Boolean SSLEnabled = (Boolean)mBeanServer.getAttribute(oname, "SSLEnabled");
if (SSLEnabled != null && SSLEnabled) {// tomcat6开始用SSLEnabled
secureValue = true;// SSLEnabled=true但secure未配置的情况
scheme = "https";
}
if (protocol != null && ("HTTP/1.1".equals(protocol) || protocol.contains("http"))) {
if (secure && "https".equals(scheme) && secureValue) {
return ((Integer)mBeanServer.getAttribute(oname, "port")).toString();
} else if (!secure && !"https".equals(scheme) && !secureValue) {
return ((Integer)mBeanServer.getAttribute(oname, "port")).toString();
}
}
}
return "";
}
Weblogic参考:
http://blog.csdn.net/yunzhu666/article/details/8662039
获取 web 服务器 port的更多相关文章
- Java获取Web服务器文件
Java获取Web服务器文件 如果获取的是服务器上某个目录下的有关文件,就相对比较容易,可以设定死绝对目录,但是如果不能设定死绝对目录,也不确定web服务器的安装目录,可以考虑如下两种方式: 方法一: ...
- 浏览器获取WEB服务器时间
/* * 获取XMLHttpRequest对象 */ function CreateXMLHttpRequest() { var xmlreq = false; if (window.ActiveXO ...
- 获取web服务器路径的方法 getResourceAsStream
1.先获取 serlvetContext对象 2.调用getResourceAsStream 在方法里 "\"表示当前web的根目录 还要拼接上具体的文件路径 ServletC ...
- 04-HTTP协议和静态Web服务器
一.HTTP协议(HyperText Transfer Protocol) 超文本传输协议,超文本是超级文本的缩写,是指超越文本限制或者超链接,比如:图片.音乐.视频.超链接等等都属于超文本. ...
- 转:浏览器与WEB服务器工作过程举例
用户通过“浏览器”访问因特网上的WEB服务器,浏览器和服务器之间的信息交换使用超文本传输协议(HTTP--HyperText Transfer Protocol). 例:用户访问东南大学主页 Http ...
- msf客户端渗透(九):获取PHP服务器shell
如果一个网页存在可以include外链的漏洞,我们可以利用这个漏洞include本机上的文件,从而获取web服务器的shell. 设置目标的IP 根据网页的路径设置参数 设置cookie 选择payl ...
- ASP.NET获取web应用程序的路径
服务器磁盘上的物理路径: HttPRuntime.AppDomainAppPath虚拟程序路径: HttpRuntime.AppDomainAppVirtualPath 任何于Request/Http ...
- web服务器获取请求客户端真实地址的方法
服务器获取客户端或者网页的请求,获取IP时需要注意,因为一个请求到达服务器之前,一般都会经过一层或者多层代理服务器,比如反向代理服务器将http://192.168.1.10:port/ 的URL反向 ...
- 如何快速建立一个测试资源Web服务器及异步获取资源(Unity3D)
背景 1.最近看了几位专栏作家的文章,几篇提到了资源通过网络的动态获取.如何建立一个快速的测试环境,不免是一个问题,也就最简单的就是假设http服务器了,微软系的当然首选的IIS了,别的也能用阿帕奇或 ...
随机推荐
- vim 私人快捷键备忘录
i 上 k 下 j 左 l 右 ( 上移一段 ) 下移一段 * 搜索关键字 d 删除 y 复制 p 粘贴 h 插入 H 头插 o 下开一行 O 上开一行 f 后跳指定关键字 F 前跳指定关键字 e 字 ...
- Matlab中添加路径与去除路径
今天在使用Matlab调用内部的PCA函数的时候,报错: 错误使用 pca输入参数太多. 如下图所示: 网上查找原因之后发现是因为我之前下载过开源的工具包toolbox,并且将它的路径add到了Mat ...
- webmin小结
centos7安装webmin https://www.cnblogs.com/andy9468/p/10537201.html webmin重置密码 重置webmin账户root的密码为例: htt ...
- 118A
#include <iostream> #include <cctype> #include <string> using namespace std; int m ...
- 纯真IP数据库格式详解 附demo
纯真版IP数据库,优点是记录多,查询速度快,它只用一个文件QQWry.dat就包含了所有记录,方便嵌入到其他程序中,也方便升级.缺点是你想要编辑它却是比较麻烦的,由于其文件格式的限制,你要直接添加IP ...
- JAVA中使用LOG4J记录日志
在项目开发中,记录错误日志是一个很有必要功能.一是方便调试:二是便于发现系统运行过程中的错误:三是存储业务数据,便于后期分析: 在java中,记录日志,有很多种方式. 比如,自己实现. 自己写类,将日 ...
- Linux配置SSH免登录
[root@Linux01 ~]# ssh-keygen #生成公私钥 [root@Linux01 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub hadoopuser@Ha ...
- linux 下查看c 函数帮助
帮助文档 man man MANUAL SECTIONS The standard sections of the manual include: User Commands System Calls ...
- GoWeb-Gin 文件上载
前些日子,我们Node.JS了一把. 如今,我们还是回到我们伟大的GO来吧 今天,带领大家继续Golang的啦,而且是个上传文件的例子 先给大家看结果 1. 如果是windows端,你需要安装post ...
- spring 对jdbc的简化
spring.xml <!-- 加载属性配置文件 --> <util:properties id="db" location="classpath:db ...