开发时一般用tomcat,然后在测试环境发布时使用的是weblogic。
对于页面提交,使用了JQuery的form的submit,出现了weblogic通过request获得方式显示正常而tomcat出现乱码的情况。所以需要对不同服务器进行不同处理。
对于JQuery的ajax的方式,需要在前端拼接带有中文的参数地址时使用encodeURL两次,然后在后端使用URLDecode(Stri,“utf-8”)的方式进行解码
以下是网络提供的判断服务器的代码,还是比较方便的
package com.roger.query.util;
import org.apache.log4j.Logger;
/**
* @ 服务器类型探测
* @Date 2011/04/13
* **/
public class ServerUtil {
public static final String GERONIMO_CLASS = "/org/apache/geronimo/system/main/Daemon.class";
public static final String JBOSS_CLASS = "/org/jboss/Main.class";
public static final String JETTY_CLASS = "/org/mortbay/jetty/Server.class";
public static final String JONAS_CLASS = "/org/objectweb/jonas/server/Server.class";
public static final String OC4J_CLASS = "/oracle/jsp/oc4jutil/Oc4jUtil.class";
public static final String ORION_CLASS = "/com/evermind/server/ApplicationServer.class";
public static final String PRAMATI_CLASS = "/com/pramati/Server.class";
public static final String RESIN_CLASS = "/com/caucho/server/resin/Resin.class";
public static final String REXIP_CLASS = "/com/tcc/Main.class";
public static final String SUN7_CLASS = "/com/iplanet/ias/tools/cli/IasAdminMain.class";
public static final String SUN8_CLASS = "/com/sun/enterprise/cli/framework/CLIMain.class";
public static final String TOMCAT_CLASS = "/org/apache/catalina/startup/Bootstrap.class";
public static final String WEBLOGIC_CLASS = "/weblogic/Server.class";
public static final String WEBSPHERE_CLASS = "/com/ibm/websphere/product/VersionInfo.class";
public static String getServerId() {
ServerUtil sd = _instance;
if (sd._serverId == null) {
if (ServerUtil.isGeronimo()) {
sd._serverId = "geronimo";
} else if (ServerUtil.isJBoss()) {
sd._serverId = "jboss";
} else if (ServerUtil.isJOnAS()) {
sd._serverId = "jonas";
} else if (ServerUtil.isOC4J()) {
sd._serverId = "oc4j";
} else if (ServerUtil.isOrion()) {
sd._serverId = "orion";
} else if (ServerUtil.isResin()) {
sd._serverId = "resin";
} else if (ServerUtil.isWebLogic()) {
sd._serverId = "weblogic";
} else if (ServerUtil.isWebSphere()) {
sd._serverId = "websphere";
}
if (ServerUtil.isJetty()) {
if (sd._serverId == null) {
sd._serverId = "jetty";
} else {
sd._serverId += "-jetty";
}
} else if (ServerUtil.isTomcat()) {
if (sd._serverId == null) {
sd._serverId = "tomcat";
} else {
sd._serverId += "-tomcat";
}
}
if (_log.isInfoEnabled()) {
_log.info("Detected server " + sd._serverId);
}
if (sd._serverId == null) {
throw new RuntimeException("Server is not supported");
}
}
return sd._serverId;
}
public static boolean isGeronimo() {
ServerUtil sd = _instance;
if (sd._geronimo == null) {
Class c = sd.getClass();
if (c.getResource(GERONIMO_CLASS) != null) {
sd._geronimo = Boolean.TRUE;
} else {
sd._geronimo = Boolean.FALSE;
}
}
return sd._geronimo.booleanValue();
}
public static boolean isJBoss() {
ServerUtil sd = _instance;
if (sd._jBoss == null) {
Class c = sd.getClass();
if (c.getResource(JBOSS_CLASS) != null) {
sd._jBoss = Boolean.TRUE;
} else {
sd._jBoss = Boolean.FALSE;
}
}
return sd._jBoss.booleanValue();
}
public static boolean isJetty() {
ServerUtil sd = _instance;
if (sd._jetty == null) {
Class c = sd.getClass();
if (c.getResource(JETTY_CLASS) != null) {
sd._jetty = Boolean.TRUE;
} else {
sd._jetty = Boolean.FALSE;
}
}
return sd._jetty.booleanValue();
}
public static boolean isJOnAS() {
ServerUtil sd = _instance;
if (sd._jonas == null) {
Class c = sd.getClass();
if (c.getResource(JONAS_CLASS) != null) {
sd._jonas = Boolean.TRUE;
} else {
sd._jonas = Boolean.FALSE;
}
}
return sd._jonas.booleanValue();
}
public static boolean isOC4J() {
ServerUtil sd = _instance;
if (sd._oc4j == null) {
Class c = sd.getClass();
if (c.getResource(OC4J_CLASS) != null) {
sd._oc4j = Boolean.TRUE;
} else {
sd._oc4j = Boolean.FALSE;
}
}
return sd._oc4j.booleanValue();
}
public static boolean isOrion() {
ServerUtil sd = _instance;
if (sd._orion == null) {
Class c = sd.getClass();
if (c.getResource(ORION_CLASS) != null) {
sd._orion = Boolean.TRUE;
} else {
sd._orion = Boolean.FALSE;
}
}
return sd._orion.booleanValue();
}
public static boolean isPramati() {
ServerUtil sd = _instance;
if (sd._pramati == null) {
Class c = sd.getClass();
if (c.getResource(PRAMATI_CLASS) != null) {
sd._pramati = Boolean.TRUE;
} else {
sd._pramati = Boolean.FALSE;
}
}
return sd._pramati.booleanValue();
}
public static boolean isResin() {
ServerUtil sd = _instance;
if (sd._resin == null) {
Class c = sd.getClass();
if (c.getResource(RESIN_CLASS) != null) {
sd._resin = Boolean.TRUE;
} else {
sd._resin = Boolean.FALSE;
}
}
return sd._resin.booleanValue();
}
public static boolean isRexIP() {
ServerUtil sd = _instance;
if (sd._rexIP == null) {
Class c = sd.getClass();
if (c.getResource(REXIP_CLASS) != null) {
sd._rexIP = Boolean.TRUE;
} else {
sd._rexIP = Boolean.FALSE;
}
}
return sd._rexIP.booleanValue();
}
public static boolean isSun() {
if (isSun7() || isSun8()) {
return true;
} else {
return false;
}
}
public static boolean isSun7() {
ServerUtil sd = _instance;
if (sd._sun7 == null) {
Class c = sd.getClass();
if (c.getResource(SUN7_CLASS) != null) {
sd._sun7 = Boolean.TRUE;
} else {
sd._sun7 = Boolean.FALSE;
}
}
return sd._sun7.booleanValue();
}
public static boolean isSun8() {
ServerUtil sd = _instance;
if (sd._sun8 == null) {
Class c = sd.getClass();
if (c.getResource(SUN8_CLASS) != null) {
sd._sun8 = Boolean.TRUE;
} else {
sd._sun8 = Boolean.FALSE;
}
}
return sd._sun8.booleanValue();
}
public static boolean isTomcat() {
ServerUtil sd = _instance;
if (sd._tomcat == null) {
Class c = sd.getClass();
if (c.getResource(TOMCAT_CLASS) != null) {
sd._tomcat = Boolean.TRUE;
} else {
sd._tomcat = Boolean.FALSE;
}
}
return sd._tomcat.booleanValue();
}
public static boolean isWebLogic() {
ServerUtil sd = _instance;
if (sd._webLogic == null) {
Class c = sd.getClass();
if (c.getResource(WEBLOGIC_CLASS) != null) {
sd._webLogic = Boolean.TRUE;
} else {
sd._webLogic = Boolean.FALSE;
}
}
return sd._webLogic.booleanValue();
}
public static boolean isWebSphere() {
ServerUtil sd = _instance;
if (sd._webSphere == null) {
Class c = sd.getClass();
if (c.getResource(WEBSPHERE_CLASS) != null) {
sd._webSphere = Boolean.TRUE;
} else {
sd._webSphere = Boolean.FALSE;
}
}
return sd._webSphere.booleanValue();
}
private ServerUtil() {
}
private static Logger _log = Logger.getLogger(ServerUtil.class);
private static ServerUtil _instance = new ServerUtil();
private String _serverId;
private Boolean _geronimo;
private Boolean _jBoss;
private Boolean _jetty;
private Boolean _jonas;
private Boolean _oc4j;
private Boolean _orion;
private Boolean _pramati;
private Boolean _resin;
private Boolean _rexIP;
private Boolean _sun7;
private Boolean _sun8;
private Boolean _tomcat;
private Boolean _webLogic;
private Boolean _webSphere;
}
相关推荐
判断中间件的类型,比如判断服务器是否是tomcat或was 等
我本机开发用的是winXP,但是上传的服务器是linux,每次上传前总是要改一下配置文件,还有其他一些什么的,现在通过判断当前服务器的类型来决定执行什么样的程序,那么php如何判断所处服务器是什么类型呢php有许多...
dk.sh.x可以扫描端口3389/3390/22以及在上述...使用方法:判断文件放在同级目录ip.txt上,在Linux主机上执行./dk.sh.x,输出结果为result_ip.txt。需要提前安装nc工具,使用日期截至到01/01/2025,后续使用可私信留言
一:php有许多系 统预定义变量,通过判断他们可以简单的判断服务器系统是 windows还是*unix, 其中相关的函数或者预定义变量如下:php_uname()、PHP_OS、DIRECTORY_SEPARATOR、PHP_SHLIB_SUFFIX、PATH_SEPARATOR ...
每次客户端发出请求后,我们根据请问报文来判断客户端的请求类型,然后根据不同的请求类型进行相应的处理,这样我们就设计了一个基本的HTTP服务器。每一次监听程序都会创建一个新的TcpClien,HttpServer类又会创建一...
php中有一个非常有用的预定义常量PATH_SEPARATOR,...因此,我们可以通过PATH_SEPARATOR输出值来判断当前服务器系统类型。 在linux系统中输出结果: <?php var_dump(PATH_SEPARATOR ); //输出结果:string(1)
除了这三个设置文件之外,Apache还使用mime.types文件用于标识不同文件对应的MIME类型,magic文件设置不同MIME类型文件的一些特殊标识,使得Apache服务器从文档后缀不能判断出文件的MIME类型时,能通过文件内容中的...
判断服务器类型和后台数据库类型;确定可执行情况 对于有些攻击者而言,一般会采取sql注入法。下面我也谈一下自己关于sql注入法的感悟。 注入法: 从理论上说,认证网页中会有型如: select * from ...
判断服务器类型和后台数据库类型; 确定可执行情况 对于有些攻击者而言,一般会采取sql注入法。下面我也谈一下自己关于sql注入法的感悟。 注入法: 从理论上说,认证网页中会有型如: select * from admin where ...
智能的系统防火墙:DDOS防火墙,能够帮助服务器抵抗包括CC攻击、UDP Flood、TCP Flood、SYN Flood等在内的各类型针对服务器攻击。ARP防火墙能够全面地彻底阻断ARP攻击。 实时的网络监控功能:当前TCP链接、当前...
主要介绍了php PATH_SEPARATOR判断当前服务器系统类型实例的相关资料,需要的朋友可以参考下
从服务器上下载文件,遇到文件后缀名和文件编码不匹配的状况,找了一些方法通过读取文件流的头二十个字节判断文件真实的类型
项目组经常会用到文件上传,但是如果在服务器端判断文件大小,那文件已经传到服务器了那也就没有任何意义了,而且打文件会造成服务器和网络的压力。 今天这个方法可以在前端就判断文件大小,否则就不上上传,支持...
针对 uploadify 所写的 .net 服务器端数据处理,可自行判断出 doc、xls、ppt、docx、xlsx、pptx 的真正类型,可自行定义文件头进行真正类型的判断
1、设置拦截规则,包括设置拦截的攻击类型,保护服务器免受ARP的攻击。 网络连接实时查看: 1、实时查看当前TCP连接、当前TCP与UDP监听情况,及时了解网络的异常状态。 网络流量实时查看: 1、实时查看当前网络...
3.网站后门辅查支持自定义白名单,可以在网站初建时或本地原始备份进行白名单制作,可减少扫描结果便于判断。 4.服务器综合管理,支持远程终端端口修改及开启,可卸载及管理危险组件。 5.开关机时间检查,可发现非正常...
Gzip可以压缩网页大小从而达到加速打开网页的速度,目前主流的浏览器几乎都支持这个功能,但开启Gzip是需要服务器支持的,在这里我们简单的使用php来判断服务器是否支持Gzip功能。 新建一个php类型文件,可命名为...
1.在MIME组件中增加了获取附件编码类型的方法,修复了webmail中某些附件编码为qp时不能正常下载 的问题; 2.增加了地址簿信息,用户信息读取返回时的长度,修复了显示数据内容时乱码的问题; 3.修改了DNS缓存的...