VerifyCode.jsp
资源名称:mxnhnews.rar [点击查看]
上传用户:sdtxjx
上传日期:2022-07-09
资源大小:2937k
文件大小:1k
源码类别:
Jsp/Servlet
开发平台:
Java
- <meta http-equiv="Content-Type" content="text/html; charset=GBK">
- <%@ page contentType="text/html; charset=gb2312" language="java" import="java.awt.*,java.awt.image.*"%>
- <%@ page import="java.util.*,javax.imageio.*,java.io.*"%>
- <%@ page import="dreamtime.dreamnews.VerifyCode"%>
- <%! String sVerifyCode; //验证码字符串 %>
- <% //设置页面不缓存
- response.setHeader("Pragma","No-cache");
- response.setHeader("Cache-Control","no-cache");
- response.setDateHeader("Expires", 0);
- response.reset();
- try{
- // 将认证码存入SESSION
- //调用 runVerifyCode(int i) ,把i改成所要的验证码位数
- VerifyCode VC = new VerifyCode();
- session.setAttribute("VerifyCode",VC.runVerifyCode(4));
- //session.setMaxInactiveInterval(60);
- // 输出图象到页面
- sVerifyCode = (String)session.getAttribute("VerifyCode");
- OutputStream outs = response.getOutputStream();
- ImageIO.write(VC.CreateImage(sVerifyCode),"JPEG",outs);
- }catch(Exception e){
- return;
- }
- %>