public void _jspInit() { _el_expressionfactory = _jspxFactory .getJspApplicationContext(getServletConfig().getServletContext()) .getExpressionFactory(); _jsp_annotationprocessor = (org.apache.AnnotationProcessor) getServletConfig() .getServletContext() .getAttribute(org.apache.AnnotationProcessor.class.getName()); }
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 final class img_jsp extends org.apache.jasper.runtime.HttpJspBase implements org.apache.jasper.runtime.JspSourceDependent { // ç»å®èå´è·å¾éæºé¢è² 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); } private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory(); private static java.util.List _jspx_dependants; private javax.el.ExpressionFactory _el_expressionfactory; private org.apache.AnnotationProcessor _jsp_annotationprocessor; public Object getDependants() { return _jspx_dependants; } public void _jspInit() { _el_expressionfactory = _jspxFactory .getJspApplicationContext(getServletConfig().getServletContext()) .getExpressionFactory(); _jsp_annotationprocessor = (org.apache.AnnotationProcessor) getServletConfig() .getServletContext() .getAttribute(org.apache.AnnotationProcessor.class.getName()); } public void _jspDestroy() {} 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, null, 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); } } }