forward问题
forward.jsp
<%@ page contentType= "text/html; charset=gb2312 " language= "java " import= "java.sql.* "
errorPage= " " %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title> 测试forward </title>
</head>
<body>
<form action= " " method= "post " name= "form ">
请输入姓名: <input type= "text " name= "names "> <br>
请输入验证码: <input type= "text " name= "password "> <br>
<input type= "submit " name= "submit " value= "验证 ">
<%
String names=request.getParameter( "names ");
String password=request.getParameter( "password ");
if(password.equals( "good ")){
%>
<jsp:forward page= "jspforward.jsp ">
<jsp:param name= "g " value= " <%=names%> "/>
<jsp:param name= "mess " value= "you are sucess! "/>
</jsp:forward >
<%
}else{
%>
<jsp:forward page= "jspforward.jsp ">
<jsp:param name= "g " value= "your password is mistake! "/>
</jsp:forward>
<% } %> </form>
</body>
</html> ghh
jspforward.jsp
<%@ page contentType= "text/html; charset=gb2312 " language= "java " import= "java.sql.* " errorPage= " " %>
<title> jspforword </title>
hello: <%=(String)request.getParameter( "g ")%>
<%=(String)request.getParameter( "mess ")%>
想实现的功能:从forward.jsp到jspforward.jsp传值
有错误说是无效的
空指针?为什么呢?
大家帮我看下
谢谢
------解决方案-------------------- 当你转到jspforward.jsp页面,并且验证为密码错误时
<%=(String)request.getParameter( "mess ")%>
会报空指针