想实现jsp页面提示效果谁给指点一下 代码详细一点
index.jsp:
----------------------------------
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>点击</title>
</head>
<body>
<form action="a.jsp">
用户名:
<input type="text" name="userName">
<br />
密码:
<input type="text" name="pwd">
提交:
<input type="submit" value="提交">
</form>
</body>
</html>
-----------------------------------------
a.jap:
----------------------------------
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>点击</title>
</head>
<body>
<%
String username = request.getParameter("userName");
String pwd = request.getParameter("pwd");
if (username.equals("1") && pwd.equals("1")) {
%>
<script>
alert("登录成功");
</script>
<%
response.sendRedirect("b.jsp");
}
%>
</body>
</html>
----------------------------------
b.jsp:
--------------------------------------
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>点击</title>
</head>
<body>
欢迎你
</body>
</html>
我想通过提交index.jsp页面 提交到a.jsp页面 如果用户名和密码等于1 提示一个消息框 alert('登录成功') 显示完消息框之后在 重定向到b.jsp页面 请问我的代码应该怎么修改 啊 急急急急急急急急
------解决方案--------------------
将
a.jsp改为
-----------------------
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>点击</title>
</head>
<body>
<%
String username = request.getParameter("userName");
String pwd = request.getParameter("pwd");
if (username.equals("1") && pwd.equals("1")) {
%>
<script>
alert("登录成功");
window.location.href="b.jsp";
</script>
<%
}
%>
</body>
</html>