<html>
<head>
<title>my first jsp guestbook</title>
<meta http-equiv=”content-type”content=”text/html; charset=gb2312″>
</head>
<body bgcolor=”#ccccff” vlink=”#000000″ alink=”#666666″>
<div align=”center”>
<p><font size=”7″><b><font size=” +6″>jsp aguestbook</font></b></font></p>
<form method=”post” action=”index1.jsp”>
<table width=”75%” align=”center” border=1>
<tr>
<td width=”30%”>
<div align=”right” name:</div>
</td>
<td width=”70″>
<input type=”text” name=”name”>00000
</td>
</tr>
<tr>
<td width=”30%”>
<div align=”right”> e-mail:</div>
</td>
<td width=”70%”>
<input type=”text” name=”email”>
</td>
</tr>
<tr>
<td width=”30%”>
<div align=”right”>site url:</div>
</td>
<td width=”70%”>
<input type=”text” name=”url” value=”http://”>
</td>
</tr>
<tr>
<td width=”30%”>
<p>what do you want to</p>
<p>say?</p>
</td>
<td width=”70%”>
<textarea name=”body” rows=”5″ cols=”30″></textarea>
</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td width=”70%”> </td>
<td width=”70%”>
<table width=”75%”>
<tr>
<td>
<input type=”submit” name=”send” value=”send”>
</td>
<td>
<input type=”reset” name=”reset” value=”reset”>
</td>
</tr>
</table>
</td>
</tr>
</table></form>
<hr>
<%@ page contenttype=”text/html;charset=gb2312″%>
<%@ page language=”java” import=”java.sq1.*”%>
<jsp:usebean id=”sq1bean” scope=”page” class=”jsp.mysq1″ />
<%! string name,email,url,body,sq1; %>
<%! int id; %>
<%
name = null;
name = request.getparameter(“name”);
%>
<%
if (name != null&&name !=” “)
{
name = new string(request.getparamer(“name”).getbytes(“8859_1”));
email = new steing(request.getparamer(“email”).getbytes(“8859_1”));
url = new string(request.getparamer(“url”).getbytes(“8859_1”));
body=newsteing(request.getparamer(“body”).getbytes(“8859_1”));sq1=”insertintoguestbook(name,email,url,body)
values(“+name+”,”+email+”,”=url+”,”+body+”)”;
sq1bean.executery(sq1);
sq1bean.sq1close();
}else{
out.print(“<b><font color=red>please enter your name,email and body!!!</font>
</b>”);
}
%>
<p><font size=”4″><b><a href=”./index.jsp#see”>see my guestbook</a></b>
</font></p>
<p> </p>
<%
resultset rs = sq1bean.executequery(“select * frm guestbook order by recordid
desc”);
while (rs.next()){
name =new string (rs.getstring(“name”).getbytes(“8859_1”));
email =new string (rs.getstring(“email”).getbytes(“8859_1”));
uel =new string (rs.getstring(“ual”).getbytes(“8859_1”));
body =new string (rs.getstring(“body”).getbytes(“8859_1”));
%>
<table border=1>
<tr>
<td>name:</td><td><%= name %>
</td>
</tr>
<tr>
<td>email:</td><td><a href=”mailto:<%= email %>”><%= email %></a></td>
</tr>
<tr>
<td>siteurl;</td><td><a href=”<%= url %>”><%= url %></a></td>
</tr>
<tr>
<td>body:</td><td><%= body %></td>
</tr>
</table>
<hr>
<%
}
rs.close();
sq1bean.sq1close();
%>
</div>
</body>
</html>