-、ImageBean.java为生成图片的javabean
二、用imagebean.jsp获得图片,代码如下:
<%@ page contentType= "image/jpeg "%>
<jsp:useBean id= "image " scope= "page " class= "image.imageBean.ImageBean "/>
<%
String str=image.getImage(0,0,response.getOutputStream());
session.setAttribute( "str ",str);
%>
三、在image.jsp中使用以下代码显示图片
<p>
生成验证码: <img src= "imagebean.jsp " >
</p>
<form action= "imagecheck.jsp " method= "post ">
<p>
请输入上面的验证码: <input type= "text " maxlenth= "4 " name= "code ">
</p>
<input type= "submit " value= "提交检验 ">
四、通过imagecheck.jsp检查验证码
在这里存在一个问题:
那就是当到达imagecheck.jsp时通过浏览器的后退键返回image.jsp时显示的是上次的图片,我的要求是应该刷新些图片显示一副新的图片
应该怎样做??
------解决方案--------------------
response.setHeader( "Pragma ", "No-cache ");
response.setHeader( "Cache-Control ", "no-cache ");
response.setDateHeader( "Expires ", 0);
------解决方案--------------------
response.setHeader( "Pragma ", "No-cache ");
response.setHeader( "Cache-Control ", "no-cache ");
response.setDateHeader( "Expires ", 0);