home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 May / CMCD0505.ISO / Software / Shareware / Programare / bugzero / console / console.jsp
Encoding:
Text File  |  2005-02-04  |  4.4 KB  |  138 lines

  1. <%@ page language="java"
  2.     contentType="text/html"
  3. %>
  4. <html>
  5. <head><title>Bugzero console</title></head>
  6. <body topmargin=0>
  7. <center>
  8. <h2>Bugzero Console</h2>
  9. <%=com.websina.VersionUID.version%>
  10. <p>
  11. <%
  12.   // WARNING: set consoleDisabled to true when all is done !!!!!!!
  13.   // defaulted to true
  14.  
  15.   boolean consoleDisabled = true;
  16.  
  17.   String cmd = request.getParameter("cmd");
  18.   boolean doDebug = com.websina.util.log.Log.doDebug();
  19.   String enableDebug = "Enable Debug";
  20.   String disableDebug = "Disable Debug";
  21.   String debug = null;
  22.   if (doDebug) {
  23.     debug = disableDebug;
  24.   } else {
  25.     debug = enableDebug;
  26.   } 
  27.   if (disableDebug.equals(cmd)) {
  28.     debug = enableDebug;
  29.   } else if (enableDebug.equals(cmd)) {
  30.     debug = disableDebug;
  31.   }
  32.  
  33.   String showLog = "Log Configuration";
  34.   String showDatabase = "DB Configuration";
  35.   String showMetaData = "Test DB Connection";
  36.   String showConnectionPool = "Connection Pool";
  37.   String showJVM = "Show JVM";
  38. %>
  39.  
  40. <% if (consoleDisabled) { %>
  41. This console has been disabled.
  42. To enable it, edit console.jsp and set consoleDisabled = false.
  43. <% } else { %>
  44. <table cellspacing=2 cellpadding=2 border=0>
  45. <tr>
  46. <td><form method="post">
  47. <input type="submit" name="cmd" value="<%=showLog%>">
  48. </form></td>
  49. <td><form method="post">
  50. <input type="submit" name="cmd" value="<%=debug%>">
  51. </form></td>
  52. <td><form method="post">
  53. <input type="submit" name="cmd" value="<%=showDatabase%>">
  54. </form></td>
  55. <td><form method="post">
  56. <input type="submit" name="cmd" value="<%=showMetaData%>">
  57. </form></td>
  58. <td><form method="post">
  59. <input type="submit" name="cmd" value="<%=showConnectionPool%>">
  60. </form></td>
  61. <td><form method="post">
  62. <input type="submit" name="cmd" value="<%=showJVM%>">
  63. </form></td>
  64. </tr>
  65. </table>
  66. </center>
  67. <pre>
  68. <% 
  69.   if (showLog.equals(cmd)) {
  70.     out.println(com.websina.util.log.Log.currentLog());
  71.   } else if (enableDebug.equals(cmd)) {
  72.     com.websina.util.log.Log.setDebug(true);
  73.     out.println("Debug is enabled!");
  74.   } else if (disableDebug.equals(cmd)) {
  75.     com.websina.util.log.Log.setDebug(false);
  76.     out.println("Debug is disabled!");
  77.   } else if (showDatabase.equals(cmd)) {
  78.     out.println(com.websina.persistence.DBManager.getConfiguration());
  79.   } else if (showMetaData.equals(cmd)) { 
  80.     String result = null;
  81.     try {
  82.       result = com.websina.persistence.DBManager.getMetaData();
  83.       out.println(result);
  84.     } catch (Exception e) {
  85.       e.printStackTrace(new java.io.PrintWriter(out));
  86.     }
  87.   } else if (showConnectionPool.equals(cmd)) { 
  88.     String result = null;
  89.     try {
  90.       result = com.websina.persistence.DBManager.getConnectionPoolInfo();
  91.       out.println(result);
  92.     } catch (Exception e) {
  93.       e.printStackTrace(new java.io.PrintWriter(out));
  94.     }
  95.   } else if (showJVM.equals(cmd)) { 
  96.     try {
  97.       out.println("<b>Java Runtime:</b>");
  98.       out.println("java version " + System.getProperty("java.version"));
  99.       out.println(System.getProperty("java.vm.name") + " " + System.getProperty("java.vm.version") + " " + System.getProperty("java.vm.vendor"));
  100.       out.println(System.getProperty("os.name") + " " + System.getProperty("os.version") + " " + System.getProperty("os.arch"));
  101.   
  102.       out.println("\n<b>Classpath:</b>");
  103.       out.println(System.getProperty("java.class.path"));
  104.  
  105.       out.println("\n<b>Web Context:</b>");
  106.       out.println(request.getContextPath()+ " (" + application.getServerInfo() + ")");
  107.  
  108.       out.println("\n<b>lib Files:</b>");
  109.       java.io.File file = new java.io.File(com.websina.bean.AppContext.getHome(), "lib");
  110.       out.println(file.getPath());
  111.       String[] fs = file.list();
  112.       if (fs != null) {
  113.         for (int i=0; i<fs.length; i++) {
  114.           out.println("  " + fs[i]);
  115.         }
  116.       }
  117.  
  118.       out.println("\n<b>ClassLoader:</b>");
  119.       out.println(Thread.currentThread().getContextClassLoader());
  120.  
  121.       out.println("\n<b>Memory Usage:</b>");
  122.       long[] memory = com.websina.util.MemoryCounter.getMemory();
  123.       out.println("Total: " + memory[0]/1024 + "K   Available: "+memory[1]/1024 + "K\n");
  124.       String[] threads = com.websina.util.ThreadCounter.lists();
  125.       out.println("<b>" + threads[0] + "</b>");
  126.       for (int i=1; i<threads.length; i++) {
  127.         out.println(threads[i]);
  128.       }
  129.     } catch (Exception e) {
  130.       e.printStackTrace(new java.io.PrintWriter(out));
  131.     }
  132.   } else { %>
  133. This console is used for trouble shooting only. You should disable it after all is done.
  134. To disable this console, edit console.jsp and set consoleDisabled = true.
  135. <% }} %>
  136. </pre>
  137. </body></html>
  138.