- 2
- 0
- 约1.78万字
- 约 15页
- 2018-05-11 发布于浙江
- 举报
代码汇
实验一:
源码:
Index.jsp
%@page contentType=text/html; charset=UTF-8 Encoding=UTF-8%
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
/TR/html4/loose.dtd
html
head
meta http-equiv=Content-Type content=text/html; charset=UTF-8
titleJSP Page/title
/head
body
h1登陆界面/h1
%
String name = loginname;
session.setAttribute(checknum, check);
%
form action=VerificationCheck.jsp method=get
姓 名:input type=text name=username/br
密 码:input type=password name=pwd /br
验证码:input type=text value= name=name/br
img src=VerificationCode.jsp?name=%=name%/
保存密码
brinput type=checkbox name=smima value=cb
brinput type=submit value=登陆 /
/form
/body
/html
验证码生成:
VerificationCode.jsp
%@page contentType=image/jpeg pageEncoding=UTF-8%
%@page import=java.awt.* %
%@page import=java.util.* %
%@page import=java.awt.image.* %
%@page import=com.sun.image.codec.jpeg.* %
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
/TR/html4/loose.dtd
html
head
meta http-equiv=Content-Type content=text/html; charset=UTF-8
titleJSP Page/title
/head
body
%!
Color getColor(int a, int b) {
if (b 255) {
b = 255;
}
Random rd = new Random();
int cr = a + rd.nextInt(b - a);
int cg = a + rd.nextInt(b - a);
int cb = a + rd.nextInt(b - a);
return new Color(cr, cg, cb);
}
%
%
int width = 130;
int height = 30;
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
Random random = new Random();
g.setColor(getColor(200, 250));
g.fillRect(0, 0, width, height);
g.setFont(new Font
原创力文档

文档评论(0)