第一个页面:
  <body>
  
  
  <jsp:useBean id="IDChkBean" class="lib.IDChkBean" scope="request"/>
  <FORM action="validate.jsp" method="post">
  输入验证码:
  <INPUT type="text" name="input" id="input">
  <INPUT type="submit" value="登陆"><br>
  <%
  String[] ids = new String[4];
  Random rnd = new Random();
  for(int i=0; i<ids.length; i++){
   int tmp = rnd.nextInt(9)+1;
   ids[i] = "0123456789".substring(tmp,tmp+1);
  }  
  %>
  <%
  for(int i=0; i<ids.length; i++){
  %>
  <IMG src="servlet/ChkImgGenerate?imgid=<%= ids[i]%>">
  <%
  }
  %>  
  </FORM>
  <% IDChkBean.setTochk(ids[0]+ids[1]+ids[2]+ids[3]);%>
  </body>---------------------------------------
第二个:
  <body>
  <jsp:useBean id="IDChkBean" class="lib.IDChkBean" scope="request"/>
  <jsp:setProperty name="IDChkBean" property="input"/>
  <%
   if(IDChkBean.validate()){
  %>
  成功!
  <%
  }
  else{
  %>
  <h1>登陆失败!</h1>
  <%
  }
  %>
  </body>=============================
第一个页面post之后,bean的属性在第二个页面中不能共享,怎么解决

解决方案 »

  1.   

    把scope="request"  换成 session 试试看
      

  2.   

    换session成功,
    不过我看书上request好像就可以满足我的要求的么,
    哪位解释一下
      

  3.   

    因为 request是指在同一个 http request范围(scope) 如果你用post 其实浏览器发了第二个请求了应给只有 forword 会传递request...
      

  4.   

    你用FORM提交到第二个页面怎么可能还是同一个Request?你的BEAN放在request域中怎么可能第2个页面取得出来?
      

  5.   

    补充 wfeng007(风),还有redirect能保存request域的变量
      

  6.   

    yingtju(蚂蚁) ( ) 信誉:82  2006-02-19 09:23:00  得分: 0  
     
       补充 wfeng007(风),还有redirect能保存request域的变量
    --------------------------------------------------------------------------
    那请教一下redirect和forword 有什么不同?