下面是JSP页面<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%
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>edit pet 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 name="pet" action="DoEditPet"  >
  
    pet_name:<input name="name"type="text" value="${sessionScope.petinfo.pet_name}"/><br/>
    pet_owner_email:<input name="email" type="text" value="${sessionScope.petinfo.pet_owner_email}"/><br/>
    <input type="reset" value="重置"/>&nbsp;<input type="submit" value="提交"/>
    
  </form> 
  </body>
</html>以下是 servlet  java 代码package Contrallor;import java.io.IOException;
import java.io.PrintWriter;import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;import dao.impl.PetinfoEditBizJdbcImpl;import entity.Petinfo;public class DoEditPet extends HttpServlet { /**
 * The doGet method of the servlet. <br>
 *
 * This method is called when a form has its tag value method equals to get.
 * 
 * @param request the request send by the client to the server
 * @param response the response send by the server to the client
 * @throws ServletException if an error occurred
 * @throws IOException if an error occurred
 */
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { HttpSession session = request.getSession();
Petinfo petinfo = (Petinfo)session.getAttribute("petinfo"); petinfo.setPet_name(request.getParameter("name"));
petinfo.setPet_owner_email(request.getParameter("email"));
System.out.println(petinfo.getPet_name());
String result =  new PetinfoEditBizJdbcImpl().edit(petinfo); if(result.equals("success"))
response.sendRedirect("/pet/showpet.jsp?id="+petinfo.getPet_id());
else
{
request.setAttribute("errormessage", "编辑错误");
request.getRequestDispatcher("/error.jsp").forward(request, response);
}
} /**
 * The doPost method of the servlet. <br>
 *
 * This method is called when a form has its tag value method equals to post.
 * 
 * @param request the request send by the client to the server
 * @param response the response send by the server to the client
 * @throws ServletException if an error occurred
 * @throws IOException if an error occurred
 */
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { doGet(request,response);
}}在更新成功后跳转到另外一个显示页面 <%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%
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>show pet 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">
-->
   <jsp:useBean id="petinfo" class="entity.Petinfo" scope="session"></jsp:useBean>
  </head>
  
  <body>
     <div align="center">
      ${petinfo.pet_id }<br />
      ${petinfo.pet_name }<br />
      
      <img alt="${petinfo.pet_name} " src="${petinfo.pet_pic}">
     </div>
  </body>
</html>