map.java
package email;
import java.util.*;
public class Map extends TreeMap{
private String name,email,action;
private int count=0;
public Map(){}
public void setName(String formName){
if (formName!=""){
name=formName;
}
}
public String getName(){
return name;
}
public void setEmail(String formEmail){
if (formEmail!=""){
email=formEmail;
System.out.println(name);
System.out.println(email);
}
}
public String getEmail(){
email=get(name).toString();
return email;
}
public void setAction(String pageAction){
action=pageAction;
}
public String getAction(){
return action;
}
}email.jsp
<%/*@ include file="copyright.html"*/%>
<%@ page isThreadSafe="false" import="java.util.*,email.Map" errorPage="error.jsp"%>
<jsp:useBean id="mymap" scope="session" class="email.Map"/>
<jsp:setProperty name="mymap" property="name" param="name"/>
<jsp:setProperty name="mymap" property="email" param="email"/>
<!-- this -->
<% mymap.setAction("add");%>
<html>
<head><title>email finder</title></head>
<body bgcolor="#ffffff" background="bacdground.gif" link="#000099">
<!-- the form table-->
<form method="get">
<table cellspacing="0" cellpadding="5">
<tr>
<td width="150"> </td>
<td align="right"><h1>Email finder</h1></td>
</tr>
<tr>
<td width="150" align="right"><b>Name</b></td>
<td align="left"><input type="text" name="name" size="35"></td>
</tr>
<tr>
<td width="150" align="right"><b>Email</b></td>
<td align="left"><input type="text" name="email" size="35"></td>
</tr>
<tr>
<td width="150"> </td>
<td align="right">Please enter a name and an email address;
</td>
</tr>
<tr>
<td width="150"> </td>
<td align="right"><input type="submit" value="add"></td>
</tr>
<!-- here we call the put-->
<%
String rname=request.getParameter("name");
String remail=request.getParameter("email");
if (rname!=null){
mymap.put(rname,remail); }
%>
<!-- the else method-->
<tr>
<td width="150"> </td>
<td align="right">the map file has <font color="blue"><%=mymap.size()%></font> entries;</td>
</tr>
<tr>
<td width="150"> </td>
<td align="right">
<a href="lookup.jsp">loopup</a> | <a href="delete.jsp">Delete</a>
</td>
</tr>
</table>
</form>
</body>
</html>
谢谢
package email;
import java.util.*;
public class Map extends TreeMap{
private String name,email,action;
private int count=0;
public Map(){}
public void setName(String formName){
if (formName!=""){
name=formName;
}
}
public String getName(){
return name;
}
public void setEmail(String formEmail){
if (formEmail!=""){
email=formEmail;
System.out.println(name);
System.out.println(email);
}
}
public String getEmail(){
email=get(name).toString();
return email;
}
public void setAction(String pageAction){
action=pageAction;
}
public String getAction(){
return action;
}
}email.jsp
<%/*@ include file="copyright.html"*/%>
<%@ page isThreadSafe="false" import="java.util.*,email.Map" errorPage="error.jsp"%>
<jsp:useBean id="mymap" scope="session" class="email.Map"/>
<jsp:setProperty name="mymap" property="name" param="name"/>
<jsp:setProperty name="mymap" property="email" param="email"/>
<!-- this -->
<% mymap.setAction("add");%>
<html>
<head><title>email finder</title></head>
<body bgcolor="#ffffff" background="bacdground.gif" link="#000099">
<!-- the form table-->
<form method="get">
<table cellspacing="0" cellpadding="5">
<tr>
<td width="150"> </td>
<td align="right"><h1>Email finder</h1></td>
</tr>
<tr>
<td width="150" align="right"><b>Name</b></td>
<td align="left"><input type="text" name="name" size="35"></td>
</tr>
<tr>
<td width="150" align="right"><b>Email</b></td>
<td align="left"><input type="text" name="email" size="35"></td>
</tr>
<tr>
<td width="150"> </td>
<td align="right">Please enter a name and an email address;
</td>
</tr>
<tr>
<td width="150"> </td>
<td align="right"><input type="submit" value="add"></td>
</tr>
<!-- here we call the put-->
<%
String rname=request.getParameter("name");
String remail=request.getParameter("email");
if (rname!=null){
mymap.put(rname,remail); }
%>
<!-- the else method-->
<tr>
<td width="150"> </td>
<td align="right">the map file has <font color="blue"><%=mymap.size()%></font> entries;</td>
</tr>
<tr>
<td width="150"> </td>
<td align="right">
<a href="lookup.jsp">loopup</a> | <a href="delete.jsp">Delete</a>
</td>
</tr>
</table>
</form>
</body>
</html>
谢谢
----->
<%@ page isThreadSafe="false" import="java.util.*," errorPage="error.jsp"%>
//去掉email.Map<jsp:setProperty name="mymap" property="name" param="name"/>
<jsp:setProperty name="mymap" property="email" param="email"/>
--------》
<jsp:setProperty name="mymap" property="Name" param="name"/>
<jsp:setProperty name="mymap" property="Email" param="email"/>
//注意大小写问题
<jsp:setProperty name="mymap" property="email" param="email"/>
------>
<jsp:setProperty name="mymap" property="Name" value="name"/>
<jsp:setProperty name="mymap" property="Email" value="email"/>