?? image_jsp.java
字號:
package org.apache.jsp.bbs;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.awt.*;
import java.awt.image.*;
import java.util.*;
import javax.imageio.*;
public final class image_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 java.util.Vector _jspx_dependants;
public java.util.List getDependants() {
return _jspx_dependants;
}
public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException {
JspFactory _jspxFactory = null;
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 {
_jspxFactory = JspFactory.getDefaultFactory();
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');
out.write('\n');
out.write('\r');
out.write('\n');
//éè??ò3??2??o′?
response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires", 0);
// ?ú?ú′??D′′?¨í??ó
int width=60, height=18;
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
// ??è?í?D?é?????
Graphics g = image.getGraphics();
//éú3é???úàà
Random random = new Random();
// éè?¨±3?°é?
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);
// ???ú2úéú155ì??éè???£?ê1í??ó?Dμ?è??¤??2?ò×±????ü3ìDòì?2aμ?
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);
}
// è????ú2úéúμ?è??¤??(4??êy×?)
String sRand="";
for (int i=0;i<4;i++){
String rand=String.valueOf(random.nextInt(10));
sRand+=rand;
// ??è??¤????ê?μ?í??ó?D
g.setColor(new Color(20+random.nextInt(110),20+random.nextInt(110),20+random.nextInt(110)));
//μ÷ó?oˉêy3?à′μ???é??àí?£??é?üê?òò?a??×óì??ó?ü£??ùò????ü?±?óéú3é
g.drawString(rand,13*i+6,16);
}
// ??è??¤??′?è?SESSION
session.setAttribute("rand",sRand);
// í??óéúD§
g.dispose();
// ê?3?í??óμ?ò3??
ImageIO.write(image, "JPEG", response.getOutputStream());
} catch (Throwable t) {
if (!(t instanceof SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
out.clearBuffer();
if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
}
} finally {
if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -