完成三个jsp页面,要求如下:在login.jsp中,输入用户名和密码,提交到select.jsp页面,该页面有一个图书
login.jsp页面:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<form action="select.jsp" method="post">
<table width="300" align="center" border="0">
<tr><td>账号:</td><td><input type="text" name="username" style="width:200"/></td></tr>
<tr><td>密码:</td><td><input type="password" name="password" style="width:200"/></td></tr>
<tr><td colspan="2" align="right"><input type="submit" value="登陆"/></td></tr>
</table>
</form>
</body>
</html>
select.jsp页面:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<%String username=request.getParameter("username");
session.setAttribute("username",username); %>
<form action="display.jsp" method="post">
<table width="300" align="center" border="0">
<tr><td>请选择书籍: </td><td><select name="book">
<option value="1" selected>Java Web应用开发基础
<option value="2">JSP程序设计
<option value="3">Java编程高手
</SELECT></td></tr>
<tr><td colspan="2" align="right"><input type="submit" value="确定"/></td></tr>
</table>
</form>
</body>
</html>
display.jsp页面
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<% String book="";
if(request.getParameter("book").equals("1")){
book="Java Web应用开发基础";
}
if(request.getParameter("book").equals("2")){
book="JSP程序设计";
}
if(request.getParameter("book").equals("3")){
book="Java编程高手";
}
%>
您好!<font color="red"><%=session.getAttribute("username") %></font>,您购买的图书是:<%=book %>
</body>
</html>
最后的效果图
等会测试成功了,就给分,谢谢了!
不懂再问,客气了
广告 您可能关注的内容 |