jsp页面的传值问题
index.jsp
<form action= "test131.jsp " method= "post ">
<label> 请输入用户名
<input name= "name " type= "text " />
</label>
<p>
<label> 请输入验证码
<input name= "password " type= "text " />
</label>
</p>
<p>
<label>
<input type= "submit " name= "Submit " value= "提交 " />
</label>
</p>
</form>
test131.jsp
<% String name=request.getParameter( "name ");
String password=request.getParameter( "password ");
if(password.equals( "go ")){
session.setAttribute( "name ",name);
session.setAttribute( "mess ", "你好,你已经验证成功! ");
}else{
session.setAttribute( "name ",name);
session.setAttribute( "mess ", "你好,请你重新登陆! ");
}
response.sendRedirect( "test132.jsp ");
%>
test132.jsp
<%
String name=(String)session.getAttribute( "name ");
String mess=(String)session.getAttribute( "mess ");
if(name.equals( "null ")){
out.println( "请通过验证! ");
}else{
out.println( "name ");
out.println( "mess ");
%>
<form action= "test131.jsp " method= "post ">
<label> 请输入姓名
<input type= "text " name= "name " />
</label>
<p>
<label> 请输入验证码
<input name= "password " type= "text " />
</label>
</p>
<p>
<label>
<input type= "submit " name= "Submit " value= "验证 " />
</label>
</p>
</form>
<% } %>
运行到是能够运行,就是name和mess的值传不过去
大家帮我看下谢谢
[解决办法]
大哥,可以传阿
ss.jsp
<%@ page contentType= "text/html; charset=gb2312 " language= "java " import= "java.sql.* " errorPage= " " %>
<% String name= "ss ";
String password= "go ";
if(password.equals( "go ")){
session.setAttribute( "name ",name);
session.setAttribute( "mess ", "你好,你已经验证成功! ");
}else{
session.setAttribute( "name ",name);
session.setAttribute( "mess ", "你好,请你重新登陆! ");
}
response.sendRedirect( "tt.jsp ");
%>
tt.jsp
<%@ page contentType= "text/html; charset=gb2312 " language= "java " import= "java.sql.* " errorPage= " " %>
<%
String name=(String)session.getAttribute( "name ");
String mess=(String)session.getAttribute( "mess ");
if(name.equals( "null ")){
out.println( "请通过验证! ");
}else{
out.println( "name: "+name);
out.println( "mess: "+mess);
%>
<form action= "ss.jsp " method= "post ">
<label> 请输入姓名
<input type= "text " name= "name " />
</label>
<p>
<label> 请输入验证码
<input name= "password " type= "text " />
</label>
</p>
<p>
<label>
<input type= "submit " name= "Submit " value= "验证 " />
</label>
</p>
</form>
<% } %>
结果:
name:ss mess:你好,你已经验证成功!