JSP,ServletsºÍJavaBeanÀ´¹¹³ÉÒ»¸öϵͳµÄ¼¸ÖÖ;¾¶
JSP²ÊÉ«ÑéÖ¤Âë
Éú³ÉÓÐ4¸öËæ»úÊý×ÖºÍÔÓÂÒ±³¾°µÄͼƬ£¬Êý×ֺͱ³¾°ÑÕÉ«»á¸Ä±ä£¬·þÎñÆ÷¶ËˢУ¨ÓÃhistory.go(-1)Ò²»á±ä£©
ÔÐͲο¼ALIBABA http://china.alibaba.com/member/showimage
²úÉúÑéÖ¤ÂëͼƬµÄÎļþ-----image.jsp
<%@ page contentType="image/jpeg" import="java.awt.*,java.awt.image.*,java.util.*,javax.imageio.*" %>
<%!
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);
}
%>
<%
//ÉèÖÃÒ³Ãæ²»»º´æ
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
Ïà¹ØÎĵµ£º
1¡¢jspÒ³ÃæÂÒÂ룺
ÔÚjspÒ³Ã濪ʼÌí¼Ó<%pageEncoding="uft-8"%>
2¡¢servletÊä³öÂÒÂ룺
ÔÚÊä³öÄÚÈÝ֮ǰ£¬ÏÈÖ´ÐÐresponse.setContentType
("text/html;charset=utf-8")
3¡¢ÔÚformÀïÓÃpost·½Ê½Ìá½»²ÎÊý£º
1£©½ÓÊÕʱ¼Órequest.setCharacterEncoding("utf-8")
2£©Ê¹ÓùýÂËÆ÷£¬ÔÚ½ÓÊÕ²ÎÊý֮ǰ£¬É趨´«µÝµÄ²ÎÊýÄ ......
µÚÒ»ÖÖ JavaScriptÁ¬½ÓÊý¾Ý¿â£º
<mce:script language="JavaScript"><!--
// ´´½¨Êý¾Ý¿â¶ÔÏó
var objdbConn = new ActiveXObject("ADODB.Connection");
// DSN×Ö·û´®
var strdsn = "Driver={SQL Server};SERVER=192.168.0.210;UID=xhb;PWD=xhb;DATABASE=books";
// ´ò¿ªÊý¾ÝÔ´
objdbConn.Open(strdsn);
// ......
ÓõÄÊÇMySqlÊý¾Ý¿â£¬ÀïÃæÓÐÊý¾Ý¿âµÄ½Å²½£¬ÔËÐÐbbs.sqlÎļþ¾Í¿ÉÒÔÁË¡£
ÓõÄMVCģʽ£¬ÓÃjsp ×öÏÔʾҳÃ棬ÓÃservlet×ö¿ØÖƲ㣬ÓÃJavaBean×öÄ£ÐͲã
ÏÂÔصØÖ·£º
http://www.800disk.com/ContentPane.aspx?down=ok&filepath=lcbjava%2fMybbs.rar
°ÑÉÏÃæµÄµØÖ·¸´ÖƵ½ä¯ÀÀÆ÷¾Í¿ÉÒÔÏÂÔØ ......
×ܵÄÀ´½²£¬JavaSever PagesTM£¨JSP£©ºÍ ΢ÈíµÄActive Sever Pages£¨ASP£©ÔÚ¼¼Êõ·½ÃæÓÐÐí¶àÏàËÆÖ®´¦¡£Á½Õ߶¼ÊÇΪ»ùÓÚWEBÓ¦ÓÃʵÏÖ¶¯Ì¬½»»¥ÍøÒ³ÖÆ×÷ÌṩµÄ¼¼Êõ»·¾³Ö§³Ö¡£Í¬µÈ³Ì¶ÈÉÏÀ´½²£¬Á½Õ߶¼Äܹ»Îª³ÌÐò¿ª·¢ÈËÔ±ÌṩʵÏÖÓ¦ÓóÌÐòµÄ±àÖÆÓë×Ô´ø×é¼þÉè¼ÆÍøÒ³´ÓÂß¼ÉÏ·ÖÀëµÄ¼¼Êõ¡£¶øÇÒÁ½Õ߶¼Äܹ»Ìæ´úCGIʹÍøÕ¾½¨ÉèÓë·¢Õ¹±äµÄ½ÏΪ ......