// ç»å®èå´è·å¾éæºé¢è² Color getRandColor(int fc, int bc) { Random random = new Random(); if (fc > 255) fc = 255; if (bc > 255) bc = 255; int r = fc + random.nextInt(bc - fc); int g = fc + random.nextInt(bc - fc); int b = fc + random.nextInt(bc - fc); return new Color(r, g, b); }
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { response.setContentType("image/jpeg"); pageContext = _jspxFactory.getPageContext( this, request, response, "/myhtml/errorpage/erroe.jsp", true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; out.write("\r\n"); out.write("\r\n"); out.write('\r'); out.write('\n'); // 设置页é¢ä¸ç¼å response.setHeader("Pragma", "No-cache"); response.setHeader("Cache-Control", "no-cache"); response.setDateHeader("Expires", 0); // å¨å åä¸å建å¾è±¡ int width = 60, height = 20; BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // è·åå¾å½¢ä¸ä¸æ Graphics g = image.getGraphics(); // çæéæºç±» Random random = new Random(); // 设å®èæ¯è² g.setColor(getRandColor(200, 250)); g.fillRect(0, 0, width, height); // 设å®åä½ g.setFont(new Font("Times New Roman", Font.PLAIN, 18)); // ç»è¾¹æ¡ // g.setColor(new Color()); // g.drawRect(0,0,width-1,height-1); // éæºäº§ç155æ¡å¹²æ°çº¿ï¼ä½¿å¾è±¡ä¸ç认è¯ç ä¸æè¢«å ¶å®ç¨åºæ¢æµå° g.setColor(getRandColor(160, 200)); for (int i = 0; i < 155; i++) { int x = random.nextInt(width); int y = random.nextInt(height); int xl = random.nextInt(12); int yl = random.nextInt(12); g.drawLine(x, y, x + xl, y + yl); } // åéæºäº§çç认è¯ç (4ä½æ°å) String sRand = ""; for (int i = 0; i < 4; i++) { String rand = String.valueOf(random.nextInt(10)); sRand += rand; // å°è®¤è¯ç æ¾ç¤ºå°å¾è±¡ä¸ g.setColor( new Color( 20 + random.nextInt(110), 20 + random.nextInt(110), 20 + random.nextInt(110))); // è°ç¨å½æ°åºæ¥çé¢è²ç¸åï¼å¯è½æ¯å // 为ç§å太æ¥è¿ï¼æ以åªè½ç´æ¥çæ g.drawString(rand, 13 * i + 6, 16); } // å°è®¤è¯ç åå ¥SESSION session.setAttribute("rand", sRand); // å¾è±¡çæ g.dispose(); // è¾åºå¾è±¡å°é¡µé¢ ImageIO.write(image, "JPEG", response.getOutputStream()); out.clear(); out = pageContext.pushBody(); } catch (Throwable t) { if (!(t instanceof SkipPageException)) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) try { out.clearBuffer(); } catch (java.io.IOException e) { } if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); else log(t.getMessage(), t); } } finally { _jspxFactory.releasePageContext(_jspx_page_context); } }
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { JspFactory _jspxFactory = null; javax.servlet.jsp.PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; try { _jspxFactory = JspFactory.getDefaultFactory(); response.setContentType("text/html;charset=ISO-8859-1"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; out.write("\r\n\r\n"); out.write("\r\n\r\n"); String strIp = (String) request.getParameter("ip"); String strCommunityString = (String) request.getParameter("cs"); String strPort = (String) request.getParameter("port"); String strTimeout = (String) request.getParameter("timeout"); String strRetries = (String) request.getParameter("retries"); String strNodeLabel = (String) request.getParameter("node"); String strNodeId = request.getParameter("nodeId"); String strFirstTime = (String) request.getParameter("firsttime"); String strWindowId = (String) request.getParameter("windowid"); // Create the querier and make the request. QueryFactory factory = new QueryFactory(); Querier querier = (Querier) factory.createQuerier(WinPagePerfSnmpQuerier.QUERIER_NAME); DeviceCommunicator deviceCommunicator = new DeviceCommunicator(); deviceCommunicator.sendQuery(querier, strIp); // Error processing if (querier.getErrorStatus() == -1) { RequestDispatcher rd = getServletContext() .getRequestDispatcher("/jsp/WTerror-handler.jsp?error=SnmpCommError"); rd.forward(request, response); return; } if (querier.getErrorStatus() == -2) { RequestDispatcher rd = getServletContext() .getRequestDispatcher("/jsp/WTerror-handler.jsp?error=NoPerfmibSnmpError"); rd.forward(request, response); return; } if (querier.getErrorStatus() != 0) { RequestDispatcher rd = getServletContext().getRequestDispatcher("/jsp/WTerror-handler.jsp?error=SnmpError"); rd.forward(request, response); return; } Map calcs = querier.getCalculations(); long[] results = (long[]) calcs.get(WinPagePerfSnmpQuerier.PAGE_RESULTS); if (results[0] < 0 || results[1] < 0 || results[2] < 0 || results[3] < 0 || results[4] < 0 || results[5] < 0 || results[6] < 0 || results[7] < 0 || results[8] < 0 || results[9] < 0) { RequestDispatcher rd = getServletContext().getRequestDispatcher("/jsp/WTerror-handler.jsp?error=SnmpError"); rd.forward(request, response); return; } Vector vPageStats = null; if (strFirstTime == null) { // Not the first time, so get the previous polled data from the session vPageStats = (Vector) session.getAttribute("vPageStats" + strWindowId); } else { // This is the first time in this JSP, so create the Vector which will contain the // polled data Random random = new Random(); strWindowId = String.valueOf(random.nextInt()); vPageStats = new Vector(); } vPageStats.add(results); session.setAttribute("vPageStats" + strWindowId, vPageStats); // This random number is used to prevent the brower from caching the IMG tags Random random = new Random(); int randomInt = random.nextInt(); out.write("\r\n\r\n"); out.write("<html>\r\n"); out.write("<head>\r\n "); out.write("<title>WebTelemetry - Graphs | Real-Time | Windows Page Performance Monitoring"); out.write("</title>\r\n "); out.write("<META HTTP-EQUIV=\"refresh\" CONTENT=\""); out.print(WTProperties.getMonitorUIRefreshRate()); out.write("; URL="); out.print(WTTools.getJspURL(request)); out.write("WTwin-page-monitor.jsp?cs="); out.print(URLEncoder.encode(strCommunityString, "UTF-8")); out.write("&ip="); out.print(strIp); out.write("&port="); out.print(strPort); out.write("&timeout="); out.print(strTimeout); out.write("&retries="); out.print(strRetries); out.write("&node="); out.print(URLEncoder.encode(strNodeLabel, "UTF-8")); out.write("&windowid="); out.print(strWindowId); out.write("&nodeId="); out.print(strNodeId); out.write("\">\r\n "); out.write( "<link rel=\"stylesheet\" type=\"text/css\" href=\"/wt-portal/css/default.css\" />\r\n "); out.write("<script type=\"text/javascript\" src=\"/wt-portal/javascript/WTtools.js\">"); out.write("</script>\r\n"); out.write("</head>\r\n"); out.write("<body>\r\n"); String title = "Graphs - Real-Time - Windows Page Performance Monitoring for Node: " + strNodeLabel; out.write("\r\n"); request.setAttribute("title", title); request.setAttribute("nodeJsp", "/wt-monitor/element/node.jsp?node=" + strNodeId); out.write("\r\n"); /* ---- c:import ---- */ org.apache.taglibs.standard.tag.el.core.ImportTag _jspx_th_c_import_0 = (org.apache.taglibs.standard.tag.el.core.ImportTag) _jspx_tagPool_c_import_url_context.get( org.apache.taglibs.standard.tag.el.core.ImportTag.class); _jspx_th_c_import_0.setPageContext(pageContext); _jspx_th_c_import_0.setParent(null); _jspx_th_c_import_0.setContext("/wt-monitor"); _jspx_th_c_import_0.setUrl("/includes/header.jsp"); int[] _jspx_push_body_count_c_import_0 = new int[] {0}; try { int _jspx_eval_c_import_0 = _jspx_th_c_import_0.doStartTag(); if (_jspx_eval_c_import_0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) { if (_jspx_eval_c_import_0 != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) { javax.servlet.jsp.tagext.BodyContent _bc = pageContext.pushBody(); _jspx_push_body_count_c_import_0[0]++; out = _bc; _jspx_th_c_import_0.setBodyContent(_bc); _jspx_th_c_import_0.doInitBody(); } do { out.write("\r\n\t"); if (_jspx_meth_c_param_0( _jspx_th_c_import_0, pageContext, _jspx_push_body_count_c_import_0)) return; out.write("\r\n\t"); if (_jspx_meth_c_param_1( _jspx_th_c_import_0, pageContext, _jspx_push_body_count_c_import_0)) return; out.write("\r\n\t"); if (_jspx_meth_c_param_2( _jspx_th_c_import_0, pageContext, _jspx_push_body_count_c_import_0)) return; out.write("\r\n"); int evalDoAfterBody = _jspx_th_c_import_0.doAfterBody(); if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN) break; } while (true); if (_jspx_eval_c_import_0 != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) out = pageContext.popBody(); _jspx_push_body_count_c_import_0[0]--; } if (_jspx_th_c_import_0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) return; } catch (Throwable _jspx_exception) { while (_jspx_push_body_count_c_import_0[0]-- > 0) out = pageContext.popBody(); _jspx_th_c_import_0.doCatch(_jspx_exception); } finally { _jspx_th_c_import_0.doFinally(); _jspx_tagPool_c_import_url_context.reuse(_jspx_th_c_import_0); } out.write("\t\r\n\t"); out.write("\r\n"); out.write("<div align=\"center\">\r\n"); out.write("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\r\n\t"); out.write("<tr>\r\n\t\t"); out.write("<td align=\"right\">"); out.write("<IMG SRC=\""); out.print(WTTools.getServletURL(request)); out.write("WTsnmpRealTimeGraphs?chart=winpagefaultchart&random="); out.print(randomInt); out.write("&windowid="); out.print(strWindowId); out.write("\" BORDER=0>"); out.write("</td>\r\n\t\t"); out.write("<td>"); out.write( "<img src=\"/wt-portal/images/spacers/spacer.gif\" height=\"1\" width=\"20\" border=\"0\" alt=\"WebTelemetry\">"); out.write("</td>\r\n\t\t"); out.write("<td>"); out.write("<IMG SRC=\""); out.print(WTTools.getServletURL(request)); out.write("WTsnmpRealTimeGraphs?chart=winpagefaultseries&random="); out.print(randomInt); out.write("&windowid="); out.print(strWindowId); out.write("\" BORDER=0>"); out.write("</td>\r\n\t"); out.write("</tr>\r\n\t"); out.write("<tr>\r\n\t\t"); out.write("<td align=\"right\">"); out.write("<IMG SRC=\""); out.print(WTTools.getServletURL(request)); out.write("WTsnmpRealTimeGraphs?chart=winpagenumchart&random="); out.print(randomInt); out.write("&windowid="); out.print(strWindowId); out.write("\" BORDER=0>"); out.write("</td>\r\n\t\t"); out.write("<td> "); out.write("</td>\r\n\t\t"); out.write("<td>"); out.write("<IMG SRC=\""); out.print(WTTools.getServletURL(request)); out.write("WTsnmpRealTimeGraphs?chart=winpagenumseries&random="); out.print(randomInt); out.write("&windowid="); out.print(strWindowId); out.write("\" BORDER=0>"); out.write("</td>\r\n\t"); out.write("</tr>\r\n\t"); out.write("<tr>\r\n\t\t"); out.write("<td align=\"right\">"); out.write("<IMG SRC=\""); out.print(WTTools.getServletURL(request)); out.write("WTsnmpRealTimeGraphs?chart=winpagetimeschart&random="); out.print(randomInt); out.write("&windowid="); out.print(strWindowId); out.write("\" BORDER=0>"); out.write("</td>\r\n\t\t"); out.write("<td> "); out.write("</td>\r\n\t\t"); out.write("<td>"); out.write("<IMG SRC=\""); out.print(WTTools.getServletURL(request)); out.write("WTsnmpRealTimeGraphs?chart=winpagetimesseries&random="); out.print(randomInt); out.write("&windowid="); out.print(strWindowId); out.write("\" BORDER=0>"); out.write("</td>\r\n\t"); out.write("</tr>\r\n"); out.write("</table>\r\n"); out.write("</div>\r\n"); out.write("<br>\r\n\r\n"); /* ---- c:import ---- */ org.apache.taglibs.standard.tag.el.core.ImportTag _jspx_th_c_import_1 = (org.apache.taglibs.standard.tag.el.core.ImportTag) _jspx_tagPool_c_import_url_context_nobody.get( org.apache.taglibs.standard.tag.el.core.ImportTag.class); _jspx_th_c_import_1.setPageContext(pageContext); _jspx_th_c_import_1.setParent(null); _jspx_th_c_import_1.setContext("/wt-monitor"); _jspx_th_c_import_1.setUrl("/includes/footer.jsp"); int[] _jspx_push_body_count_c_import_1 = new int[] {0}; try { int _jspx_eval_c_import_1 = _jspx_th_c_import_1.doStartTag(); if (_jspx_th_c_import_1.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) return; } catch (Throwable _jspx_exception) { while (_jspx_push_body_count_c_import_1[0]-- > 0) out = pageContext.popBody(); _jspx_th_c_import_1.doCatch(_jspx_exception); } finally { _jspx_th_c_import_1.doFinally(); _jspx_tagPool_c_import_url_context_nobody.reuse(_jspx_th_c_import_1); } out.write("\r\n\t\r\n"); out.write("</body>\r\n"); out.write("</html>"); } catch (Throwable t) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) out.clearBuffer(); if (pageContext != null) pageContext.handlePageException(t); } finally { if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext); } }