一、实验原理
1、方法简介
setAttribute()方法,用于设置request中的属性及其属性值。
getAttribute()方法,用于返回指定的属性值,若不存在指定的属性,就返回null。
2、模拟登陆过程图示:
二、实验内容
1、创建四个jsp文件,按原理图示,分别命名为login.jsp,check.jsp,suc.jsp,err.jsp。
2、创建页面内容
(1)登录界面login.jsp,代码如下:
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
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 'login.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="check.jsp" method="post">
用户名:
<input type="text" name="name"/