用Javascript查看Tomcat运行情况

时间:2010-04-14 12:15:10  来源:第二电脑网  作者:第二电脑网

  第二电脑网导读:"java.util.Properties"%> <%@page import="java.math.BigDecimal"%> <%@page import="java.net.InetAddress"%> <%@page import="java.util.Enumeration;" %> <style type="text/css"> image {     border: 0px;     margin: 0...
  正文:  代码如下,

 <%@page import="java.text.NumberFormat"%>
<%@page import="java.util.Properties"%>
<%@page import="java.math.BigDecimal"%>
<%@page import="java.net.InetAddress"%>
<%@page import="java.util.Enumeration;" %>

<style type="text/Css">
image {
    border: 0px;
    margin: 0px;
    padding: 0px;
    clear: both;
}

.img2 {
    margin-left: -3px;
}
</style>
<table style="width: 700; text-align: left; font-size: 9pt;">
    <tr>
        <td>
        <%
        if(request.getParameter("GC") != null){
          System.gc();
        }
Runtime lRuntime = Runtime.getRuntime();
long memTotal = lRuntime.totalMemory();
long memLeft = lRuntime.freeMemory();
long memMax = lRuntime.maxMemory();
long unasigned = memMax - memTotal;
double usePercentage = (memTotal - memLeft) * 1.0/ memMax; 
double usablePercentage = memLeft * 1.0 / memMax;
double unasignedunasignedPercentage = unasigned * 1.0 / memMax;
out.println("<div style='width: 750;'><nobr>");
out.println("<image alt='Memory Used' src='images/memUsed.gif' width='" + usePercentage * 700 + "' height='10px'/>");
out.println("<image alt='Memory Left' class='img2' src='images/memLeft.gif' width='" + usablePercentage * 700 + "' height='10px' />");
out.println("<image alt='Memory Unsigned' class='img2' src='images/memUnsinged.gif' width='" + unasignedPercentage * 700 + "' height='10px' />");
out.println("<form>");
out.println("<input type='submit' value='Run GC' width='50' id='GC' name='GC' />");
out.println("</form>");
out.println("</nobr></div><br>");
%> <image src="images/memUsed.gif"
            style="width: 30px; height : 15px;" /> Memory
        Used            <font
            color="red"><%=round((memTotal - memLeft) * 1.0/1024/1024, 2) %></font>
        MB<br>
&nbsp
<image src="images/memLeft.gif"

            style="width: 30px; height : 15px;" /> Memory
        Left              
        <font color="red"><%=round(memLeft * 1.0/1024/1024, 2) %></font> MB<br>
        <image src="images/memUnsinged.gif"
            style="width: 30px; height : 15px;" /> Memory
        Unsigned    <font color="red"><%=round(unasigned * 1.0/1024/1024, 2) %></font>
        MB<br>
        <br>
        <br>
        <br>
        <br> 


"用Javascript查看Tomcat运行情况"由第二电脑网原创提供,转载请注明:http://www.002pc.com/master/College/Programming/JavaScript/13619.html


关键字:

关于《用Javascript查看Tomcat运行情况》文章的评论

站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td