session取验证码问题,同一用户为什么有两个session

 为什么我登录的时候输入验证码和产生的验证码不匹配,打印了一下session发现生成验证码的session和登录时获取的session不是一个,一个用户不是应该只有一个session吗,求解
# 产生验证码的session
// 将图像输出到客户端
           ServletOutputStream sos = response.getOutputStream();
           ByteArrayOutputStream baos = new ByteArrayOutputStream();
           ImageIO.write(image, "JPEG", baos);
           byte[] buffer = baos.toByteArray();
           response.setContentLength(buffer.length);
           sos.write(buffer);
           baos.close();
           sos.close();
           // 将验证码放到 session 中
           session.setAttribute("checkCode", new String(rands));
           System.out.println("1"+session);


## 验证时的session
private String name;
    private String password;
    private String checkcode;
    private String check;
    private HttpServletRequest request;
    private HttpSession session;

    public LoginAction() {

        request =ServletActionContext.getRequest();
        session = request.getSession();
    }
    public String execute() throws Exception {
        String checkcode1=(String)session.getAttribute("checkCode");
        System.out.println("2"+session);

这两个打印出来的session不同,求解怎么办



你怎么验证的?同一个浏览器sessionid一样的,自己看下是不是和这个问题相似

http://bbs.csdn.net/topics/392094757

session出现两个,说明你是创建了两个session对象,好好找找代码的细节之处把