1
1 <%@ page contentType="text/html;charset=gb2312" %> 2 <%@ page import="java.util.*,java.io.*,javax.servlet.*,javax.servlet.http.*,java.lang.*" %> 3 <% 4 /******************************************************************** 5 * Title: JspEnv v 6 * Description : JSP环境探针 7 * CopyRight:(c) 2005 www.soho.net.ru 8 * @author: 若影 9 * @version: 1.0 10 * @Data: 2005-1-1 12:00:00 11 *********************************************************************/ 12 13 long timePageStart = System.currentTimeMillis(); 14 %> 15 <% 16 class EnvServlet 17 { 18 public long timeUse=0; 19 public Hashtable htParam=new Hashtable(); 20 private Hashtable htShowMsg=new Hashtable(); 21 public void setHashtable() 22 { 23 Properties me=System.getProperties(); 24 Enumeration em=me.propertyNames(); 25 while(em.hasMoreElements()) 26 { 27 String strKey=(String)em.nextElement(); 28 String strValue=me.getProperty(strKey); 29 htParam.put(strKey,strValue); 30 } 31 } 32 public void getHashtable(String strQuery) 33 { 34 Enumeration em=htParam.keys(); 35 while(em.hasMoreElements()) 36 { 37 String strKey=(String)em.nextElement(); 38 String strValue=new String(); 39 if(strKey.indexOf(strQuery,0)>=0) 40 { 41 strValue=(String)htParam.get(strKey); 42 htShowMsg.put(strKey,strValue); 43 } 44 } 45 } 46 public String queryHashtable(String strKey) 47 { 48 strKey=(String)htParam.get(strKey); 49 return strKey; 50 } 51 public long test_int() 52 { 53 long timeStart = System.currentTimeMillis(); 54 int i=0; 55 while(i<3000000)i++; 56 long timeEnd = System.currentTimeMillis(); 57 long timeUse=timeEnd-timeStart; 58 return timeUse; 59 } 60 public long test_sqrt() 61 { 62 long timeStart = System.currentTimeMillis(); 63 int i=0; 64 double db=(double)new Random().nextInt(1000); 65 while(i<200000){db=Math.sqrt(db);i++;} 66 long timeEnd = System.currentTimeMillis(); 67 long timeUse=timeEnd-timeStart; 68 return timeUse; 69 } 70 } 71 %> 72 <% 73 EnvServlet env=new EnvServlet(); 74 env.setHashtable(); 75 String action=new String(" "); 76 String act=new String("action"); 77 if(request.getQueryString()!=null&&request.getQueryString().indexOf(act,0)>=0)action=request.getParameter(act); 78 %> 79 <html> 80 <head> 81 <title>JSP 探针</title> 82 <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 83 <style> 84 A { COLOR: #000000; TEXT-DECORATION: none} 85 A:hover { COLOR: #f58200} 86 body,td,span { font-size: 9pt} 87 .input { BACKGROUND-COLOR: #ffffff;BORDER:#f58200 1px solid;FONT-SIZE: 9pt} 88 .backc { BACKGROUND-COLOR: #f58200;BORDER:#f58200 1px solid;FONT-SIZE: 9pt;color:white} 89 .PicBar { background-color: #f58200; border: 1px solid #000000; height: 12px;} 90 .tableBorder {BORDER-RIGHT: #183789 1px solid; BORDER-TOP: #183789 1px solid; BORDER-LEFT: #183789 1px solid; BORDER-BOTTOM: #183789 1px solid; BACKGROUND-COLOR: #ffffff; WIDTH: 760;} 91 .divcenter { 92 position:absolute; 93 height:30px; 94 z-index:1000; 95 left: 101px; 96 top: 993px; 97 } 98 </STYLE> 99 <script language="javascript"> 100 function showsubmenu(sid) 101 { 102 whichEl = eval("submenu" + sid); 103 if (whichEl.style.display == "none") 104 { 105 eval("submenu" + sid + ".style.display="";"); 106 eval("txt" + sid + ".innerHTML="<a href='#' title='关闭此项'><font face='Wingdings' color=#FFFFFF>x</font></a>";"); 107 } 108 else 109 { 110 eval("submenu" + sid + ".style.display="none";"); 111 eval("txt" + sid + ".innerHTML="<a href='#' title='打开此项'><font face='Wingdings' color=#FFFFFF>y</font></a>";"); 112 } 113 } 114 </SCRIPT> 115 </head> 116 <body topmargin="0" leftmargin="0"> 117 <CENTER> 118 <table width="760" border="0" cellpadding="0" cellspacing="0"> 119 <tr> 120 <td width="30%"><P style="MARGIN-TOP: 0px; MARGIN-BOTTOM: -8px"> <STRONG 121 style="FONT-SIZE: 14pt">JSP探针</STRONG></td> 122 <td width="70%" align="center"><font color=red>欢迎访问<a href="http://free3.e-168.cn/cnforum/">JSP智库</a>,下载最新版程序<br> 123 <a href="http://free3.e-168.cn/cnforum/jspenv.rar">直接下载最新版本</a></font></td> 124 </tr> 125 </table> 126 选项:<a href="#ServerInfo">服务器相关参数</a> | <a href="#JAVAInfo">JAVA相关参数</a> | <a href="#Paramter">参数查询</a> | <a href="#ServerAbility">服务器运算能力</a> 127 | <a href="#ISpeedTest">服务器连接速度</a> 128 | <a href="javascript:location.reload()">刷新</a><a name="ServerInfo"></a> 129 <table border="0" cellpadding="0" cellspacing="1" class="tableBorder"> 130 <tr> 131 <td height="22" align="center" bgcolor="#f58200" onclick="showsubmenu(0)"><font color=#FFFFFF><strong>服务器相关参数</strong></font> 132 133 <a href="#top" title="返回顶部"><font face='Webdings' color=#FFFFFF>5</font></a> <span id=txt0 name=txt0><a href='#' title='关闭此项'><font face='Wingdings' color=#FFFFFF>x</font></a></span> 134 </td> 135 </tr> 136 <tr> 137 <td style="display" id='submenu0'><table border=0 width=100% cellspacing=1 cellpadding=3 bgcolor="#f58200"> 138 <tr bgcolor="#FFFFFF" height="22"> 139 <td width="130"> 服务器名</td> 140 <td colspan="3" height="22"> <%= request.getServerName() %>(<%=request.getRemoteAddr()%>)</td> 141 </tr> 142 <tr bgcolor="#FFFFFF" height="22"> 143 <td> 服务器操作系统</td> 144 <td colspan="3"> <%=env.queryHashtable("os.name")%> <%=env.queryHashtable("os.version")%> 145 <%=env.queryHashtable("sun.os.patch.level")%></td> 146 </tr> 147 <tr bgcolor="#FFFFFF" height="22"> 148 <td> 服务器操作系统类型</td> 149 <td> <%=env.queryHashtable("os.arch")%></td> 150 <td> 服务器操作系统模式</td> 151 <td> <%=env.queryHashtable("sun.arch.data.model")%>位</td> 152 </tr> 153 <tr bgcolor="#FFFFFF" height="22"> 154 <td> 服务器所在地区</td> 155 <td> <%=env.queryHashtable("user.country")%></td> 156 <td> 服务器语言</td> 157 <td> <%=env.queryHashtable("user.language")%></td> 158 </tr> 159 <tr bgcolor="#FFFFFF" height="22"> 160 <td> 服务器时区</td> 161 <td> <%=env.queryHashtable("user.timezone")%></td> 162 <td> 服务器时间</td> 163 <td> <%=new java.util.Date()%> </td> 164 </tr> 165 <tr bgcolor="#FFFFFF" height="22"> 166 <td> 服务器解译引擎</td> 167 <td width="170"> <%= getServletContext().getServerInfo() %></td> 168 <td width="130"> 服务器端口</td> 169 <td width="170"> <%= request.getServerPort() %></td> 170 </tr> 171 <tr bgcolor="#FFFFFF" height="22"> 172 <td height="22"> 当前用户</td> 173 <td height="22" colspan="3"> <%=env.queryHashtable("user.name")%></td> 174 </tr> 175 <tr bgcolor="#FFFFFF" height="22"> 176 <td> 用户目录</td> 177 <td colspan="3"> <%=env.queryHashtable("user.dir")%></td> 178 </tr> 179 <tr bgcolor="#FFFFFF" height="22"> 180 <td align=left bgcolor="#FFFFFF"> 本文件实际路径</td> 181 <td height="8" colspan="3" bgcolor="#FFFFFF"> <%=request.getRealPath(request.getServletPath())%></td> 182 </tr> 183 </table> 184 </td> 185 </tr> 186 </table> 187 <a name="JAVAInfo" id="JAVAInfo"></a><br> 188 <table border="0" cellpadding="0" cellspacing="1" class="tableBorder"> 189 <tr> 190 <td height="22" align="center" bgcolor="#f58200" onclick="showsubmenu(1)"><font color=#FFFFFF><strong>JAVA相关参数</strong></font> 191 <a href="#top" title="返回顶部"><font face='Webdings' color=#FFFFFF>5</font></a> 192 <span id=txt1 name=txt1><a href='#' title='关闭此项'><font face='Wingdings' color=#FFFFFF>x</font></a></span> 193 </td> 194 </tr> 195 <tr> 196 <td style="display" id='submenu1'> 197 <table border=0 width=100% cellspacing=1 cellpadding=3 bgcolor="#f58200"> 198 <tr bgcolor="#fcc79b" height="22"> 199 <td width="30%"> 名称</td> 200 <td width="50%" height="22"> 英文名称</td> 201 <td width="20%" height="22"> 版本</td> 202 </tr> 203 <tr bgcolor="#FFFFFF" height="22"> 204 <td width="30%"> JAVA运行环境名称</td> 205 <td width="50%" height="22"> <%=env.queryHashtable("java.runtime.name")%></td> 206 <td width="20%" height="22"> <%=env.queryHashtable("java.runtime.version")%></td> 207 </tr> 208 <tr bgcolor="#FFFFFF" height="22"> 209 <td width="30%"> JAVA运行环境说明书名称</td> 210 <td width="50%" height="22"> <%=env.queryHashtable("java.specification.name")%></td> 211 <td width="20%" height="22"> <%=env.queryHashtable("java.specification.version")%></td> 212 </tr> 213 <tr bgcolor="#FFFFFF" height="22"> 214 <td width="30%"> JAVA虚拟机名称</td> 215 <td width="50%" height="22"> <%=env.queryHashtable("java.vm.name")%></td> 216 <td width="20%" height="22"> <%=env.queryHashtable("java.vm.version")%></td> 217 </tr> 218 <tr bgcolor="#FFFFFF" height="22"> 219 <td width="30%"> JAVA虚拟机说明书名称</td> 220 <td width="50%" height="22"> <%=env.queryHashtable("java.vm.specification.name")%></td> 221 <td width="20%" height="22"> <%=env.queryHashtable("java.vm.specification.version")%></td> 222 </tr> 223 <% 224 float fFreeMemory=(float)Runtime.getRuntime().freeMemory(); 225 float fTotalMemory=(float)Runtime.getRuntime().totalMemory(); 226 float fPercent=fFreeMemory/fTotalMemory*100; 227 %> 228 <tr bgcolor="#FFFFFF" height="22"> 229 <td height="22"> JAVA虚拟机剩余内存:</td> 230 <td height="22" colspan="2"><img align=absmiddle class=PicBar width='<%=0.85*fPercent%>%'> <%=fFreeMemory/1024/1024%>M 231 </td> 232 </tr> 233 <tr bgcolor="#FFFFFF" height="22"> 234 <td height="22"> JAVA虚拟机分配内存</td> 235 <td height="22" colspan="2"><img align=absmiddle class=PicBar width='85%'> <%=fTotalMemory/1024/1024%>M 236 </td> 237 </tr> 238 </table> 239 <table border=0 width=100% cellspacing=1 cellpadding=3 bgcolor="#f58200"> 240 <tr bgcolor="#fcc79b" height="22"> 241 <td width="30%"> 参数名称</td> 242 <td width="70%" height="22"> 参数路径</td> 243 </tr> 244 <tr bgcolor="#FFFFFF" height="22"> 245 <td width="30%"> java.class.path </td> 246 <td width="70%" height="22"> <%=env.queryHashtable("java.class.path").replaceAll(env.queryHashtable("path.separator"),env.queryHashtable("path.separator")+"<br> ")%> 247 </td> 248 </tr> 249 <tr bgcolor="#FFFFFF" height="22"> 250 <td width="30%"> java.home</td> 251 <td width="70%" height="22"> <%=env.queryHashtable("java.home")%></td> 252 </tr> 253 <tr bgcolor="#FFFFFF" height="22"> 254 <td width="30%"> java.endorsed.dirs</td> 255 <td width="70%" height="22"> <%=env.queryHashtable("java.endorsed.dirs")%></td> 256 </tr> 257 <tr bgcolor="#FFFFFF" height="22"> 258 <td width="30%"> java.library.path</td> 259 <td width="70%" height="22"> <%=env.queryHashtable("java.library.path").replaceAll(env.queryHashtable("path.separator"),env.queryHashtable("path.separator")+"<br> ")%> 260 </td> 261 </tr> 262 <tr bgcolor="#FFFFFF" height="22"> 263 <td width="30%"> java.io.tmpdir</td> 264 <td width="70%" height="22"> <%=env.queryHashtable("java.io.tmpdir")%></td> 265 </tr> 266 </table> 267 </td> 268 </tr> 269 </table> 270 <a name="Paramter" id="Paramter"></a><br> 271 <form action="?action=query" method="post" name="queryform"> 272 <table border="0" cellpadding="0" cellspacing="1" class="tableBorder"> 273 <tr> 274 <td height="22" align="center" bgcolor="#f58200" onclick="showsubmenu(2)"><font color=#FFFFFF><strong>参数查询</strong></font> 275 <a href="#top" title="返回顶部"><font face='Webdings' color=#FFFFFF>5</font></a> 276 <span id=txt2 name=txt2><a href='#' title='关闭此项'><font face='Wingdings' color=#FFFFFF>x</font></a></span> 277 </td> 278 </tr> 279 <tr> 280 <td style="display" id='submenu2'> 281 <table border=0 width=100% cellspacing=1 cellpadding=3 bgcolor="#f58200"> 282 <tr bgcolor="#fcc79b" height="22"> 283 <td> 请查询系统的参数信息(<a href="#" onClick="document.queryform.submit()">枚举所有参数信息</a>)</td> 284 </tr> 285 <tr bgcolor="#FFFFFF" height="22"> 286 <td align=center> 287 <input type="text" name="query" class="input" size="70"> 288 <input type="submit" value="提交" class="backc"> 289 <input type="reset" value="重置" class="backc"> </td> 290 </tr> 291 </table> 292 <table border=0 width=100% cellspacing=1 cellpadding=3 bgcolor="#f58200"> 293 <% 294 if(action.equals("query")) 295 { 296 String query=request.getParameter("query"); 297 env.getHashtable(query); 298 if(env.htShowMsg.size()>0) 299 out.println("<tr bgcolor="#fcc79b" height="22"> <td> 参数名称</td> <td> 参数信息</td> </tr>"); 300 else 301 out.println("<tr bgcolor="#fcc79b" height="22"> <td> <font color=red>出错信息:</font></td> <td> <font color=red>没有找到你所查询的内容,请输入所要查询的参数,如果不确认,可以进行抽象查询,输入所包含字母。</font></td> </tr>"); 302 Enumeration em=env.htShowMsg.keys(); 303 while(em.hasMoreElements()) 304 { 305 String strParam=(String)em.nextElement(); 306 String strParamValue=(String)env.htShowMsg.get(strParam); 307 if(strParam.indexOf(".path",0)>=0){strParamValue=strParamValue.replaceAll(env.queryHashtable("path.separator"),env.queryHashtable("path.separator")+"<br> ");} 308 out.println ("<tr bgcolor="#FFFFFF" height="22"><td width="30%"> "+strParam+"</td><td width="70%"> "+strParamValue+"</td></tr>"); 309 } 310 } 311 %> 312 </table> 313 </td> 314 </tr> 315 </table> 316 </form> 317 <a name="ServerAbility" id="ServerAbility"></a> 318 <table border="0" cellpadding="0" cellspacing="1" class="tableBorder"> 319 <tr> 320 <td height="22" align="center" bgcolor="#f58200" onclick="showsubmenu(3)"><font color=#FFFFFF><strong>服务器运算能力</strong></font> 321 <a href="#top" title="返回顶部"><font face='Webdings' color=#FFFFFF>5</font></a> 322 <span id=txt3 name=txt3><a href='#' title='关闭此项'><font face='Wingdings' color=#FFFFFF>x</font></a></span> 323 </td> 324 </tr> 325 <tr> 326 <td style="display" id='submenu3'> <table border=0 width=100% cellspacing=1 cellpadding=3 bgcolor="#f58200"> 327 <tr bgcolor="#fcc79b" height="22"> 328 <td colspan="3"> <font face='Webdings'>4</font> 让服务器执行300万次加法(<font color="#000000">整数运算</font>)和20万次开方(浮点运算),记录其所使用的时间。 329 </td> 330 </tr> 331 <tr height="22"bgcolor="#FFFFFF" > 332 <td align=center bgcolor="#FFFFFF"><font color="#000000">可 供 参 考 的 333 服 务 器 列 表</font></td> 334 <td align="center">整数运算</td> 335 <td align="center">浮点运算</td> 336 </tr> 337 <tr bgcolor="#FFFFFF" height="22"> 338 <td align=left> 公司的电脑 (CPU:Celeron 1G 内存:256M)</td> 339 <td align="center">60 毫秒</td> 340 <td align="center">70 毫秒</td> 341 </tr> 342 <tr bgcolor="#FFFFFF" height="22"> 343 <td align=left> 家里的电脑 (CPU:Duron 1G 内存:384M) </td> 344 <td align="center">20 毫秒</td> 345 <td align="center">10 毫秒</td> 346 </tr> 347 <tr bgcolor="#FFFFFF" height="22"> 348 <td align=left> <a href="http://free3.e-168.cn/cnforum/jspenv.jsp" target="_blank">中国网聚服务器 349 (CPU:Intel Pentium III 1G 内存:768M)</a></td> 350 <td align="center">20 毫秒</td> 351 <td align="center">3 毫秒</td> 352 </tr> 353 <tr bgcolor="#FFFFFF" height="22"> 354 <td align=left> <a href="http://ibmclub.hust.edu.cn/myweb/ggyy/jspenv.jsp" target="_blank">IBM俱乐部 355 (CPU:IIntel(R) Celeron(R) CPU 1.70G 内存:256M)</a></td> 356 <td align="center">3 毫秒 </td> 357 <td align="center">7 毫秒</td> 358 </tr> 359 <tr bgcolor="#FFFFFF" height=25> 360 <td align=left> <font color=red>您正在使用的这台服务器</font> <INPUT name="button2" type="button" class=backc onclick="javascript:location.reload()" value="重新测试"> 361 </td> 362 <td align="center"><font color=red><%=env.test_int()%> 毫秒</font></td> 363 <td align="center"><font color=red><%=env.test_sqrt()%> 毫秒</font></td> 364 </tr> 365 </table></td> 366 </tr> 367 </table> 368 <a name="ISpeedTest" id="ISpeedTest"></a><br> 369 <% 370 if(action.equals("SpeedTest")) 371 { 372 %> 373 <div id="testspeed" align="center"> 374 <table width="200" border="0" cellspacing="0" cellpadding="0" class="divcenter"> 375 <tr> 376 <td height="30" align=center><p><font color="#000000"><span id=txt5>网速测试中,请稍候...</span></font></p></td> 377 </tr> 378 </table> 379 </div> 380 <%}%> 381 382 <table border="0" cellpadding="0" cellspacing="1" bgcolor="#f58200" class="tableBorder"> 383 <tr> 384 <td height="25" align="center" bgcolor="#f58200" onclick="showsubmenu(4)"><font color="#FFFFFF"><strong>服务器连接速度</strong></font> 385 386 <a href="#top" title="返回顶部"><font face='Webdings' color=#FFFFFF>5</font></a> <span id=txt4 name=txt4><a href='#' title='关闭此项'><font face='Wingdings' color=#FFFFFF>x</font></a></span> 387 388 </td> 389 </tr> 390 <tr> 391 <td bgcolor="#F8F9FC" style="display" id='submenu4'> <table width="100%" border="0" cellspacing=1 cellpadding=3 bgcolor="#f58200"> 392 <tr bgcolor="#FFFFFF"> 393 <td width="80">接入设备</td> 394 <td width="420"> 连接速度(理想值)</td> 395 <td width="100">下载速度(理想值)</td> 396 </tr> 397 <tr bgcolor="#FFFFFF"> 398 <td>56k Modem</td> 399 <td><img align=absmiddle class=PicBar width='1%'> 56 Kbps</td><td> 7.0 k/s</td> 400 </tr> 401 <tr bgcolor="#FFFFFF"> 402 <td>64k ISDN</td> 403 <td><img align=absmiddle class=PicBar width='1%'> 64 Kbps</td><td> 8.0 k/s</td> 404 </tr> 405 <tr bgcolor="#FFFFFF"> 406 <td>512k ADSL</td> 407 <td><img align=absmiddle class=PicBar width='5%'> 512 Kbps</td><td> 64.0 k/s</td> 408 </tr> 409 <tr bgcolor="#FFFFFF"> 410 <td height="19">1.5M Cable</td> 411 <td><img align=absmiddle class=PicBar width='15%'> 1500 Kbps</td><td> 187.5 k/s</td> 412 </tr> 413 <tr bgcolor="#FFFFFF"> 414 <td>5M FTTP</td> 415 <td><img align=absmiddle class=PicBar width='50%'> 5000 Kbps</td><td> 625.0 k/s</td> 416 </tr> 417 <tr bgcolor="#FFFFFF"> 418 <td>当前连接速度</td> 419 <% 420 if(action.equals("SpeedTest")) 421 { 422 out.println("<script language='JavaScript'>var tSpeedStart=new Date();</script>") ; 423 out.println("<!-- "); 424 for(int i=0;i<1000;i++) 425 {out.println("####################################################################################################");} 426 out.println("--> "); 427 out.println("<script language='JavaScript'>var tSpeedEnd=new Date();</script> "); 428 out.println("<script language='JavaScript'>"); 429 out.println("var iSpeedTime=0;iSpeedTime=(tSpeedEnd - tSpeedStart) / 1000;"); 430 out.println("if(iSpeedTime>0) iKbps=Math.round(Math.round(100 * 8 / iSpeedTime * 10.5) / 10); else iKbps=10000 ;"); 431 out.println("var iShowPer=Math.round(iKbps / 100);"); 432 out.println("if(iShowPer<1) iShowPer=1; else if(iShowPer>82) iShowPer=82;"); 433 out.println("</script> "); 434 out.println("<script language='JavaScript'>") ; 435 out.println("document.write('<td><img align=absmiddle class=PicBar width="' + iShowPer + '%">' + iKbps + ' Kbps');"); 436 out.println("</script> "); 437 out.println("</td><td> <a href='?action=SpeedTest' title=测试连接速度><u>"); 438 out.println("<script language='JavaScript'>"); 439 out.println("document.write(Math.round(iKbps/8*10)/10+ ' k/s');"); 440 out.println("</script> ") ; 441 out.println("</u></a></td>"); 442 %> 443 <script> 444 txt5.innerHTML="网速测试完毕!" 445 testspeed.style.visibility="hidden" 446 </script> 447 <% 448 } 449 else 450 {out.println("<td></td><td> <a href='?action=SpeedTest' title=测试连接速度><u>开始测试</u></a></td>");} 451 %> 452 </tr> 453 </table></td> 454 </tr> 455 </table> 456 <% 457 long timePageEnd = System.currentTimeMillis(); 458 long timePageUse=timePageEnd-timePageStart; 459 %> 460 <table border=0 cellpadding=0 cellspacing=1 class=tableBorder> 461 <tr> 462 <td height="59" align=center>Copyright ? 2005-2008 , All Rights Reserved. 463 <br> 464 欢迎访问★<a href="http://free3.e-168.cn/cnforum/">JSP智库</a>★,下载最新版程序<br> 465 页面执行时间:约<%=timePageUse%>毫秒 JspEnv V1.0</td> 466 </tr> 467 </table> 468 </CENTER> 469 </body> 470 </html>