为了完成老师给的简单的jsp模拟登录,利用jsp:forward实现
index.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>$Title$</title>
</head>
<body>
<h1>模拟登陆</h1>
<form action="forward.jsp">
<input type="text",name = "id" id = "id">账号<br>
<input type="password",name = "pwq" id = "pwq">密码<br>
<input type="submit" value="登录">
</form>
</body>
</html>
在forward中尝试判断 ,密码是否正确,可是却一直获取不到,打印输出是null???为什么 哪里写错了
forward.jsp
<%--
Created by IntelliJ IDEA.
User: Murphy
Date: 2019-05-18
Time: 21:57
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
String inId = request.getParameter("id");
String inPwd = request.getParameter("pwq");
%>
<%= inId%>
<%= inPwd%>
<%
String rightId = "123";
String rightpwd = "123";
String access ;
if(inId == rightId && inPwd == rightpwd)
{
access = "登录成功";
out.print("Yes");
}else{
access = "You are not login";
}
%>
<%= access%>
<%
if(access == "登录成功"){ %>
<jsp:forward page="homepage.jsp">
<jsp:param value="<% =accsess %>" name="access" />
</jsp:forward>
<% } else{ %>
alert("密码错误!")
<% response.sendRedirect("index.jsp"); %>
<% }%>