Java jsp中的response.sendRedirect错误

Java jsp中的response.sendRedirect错误,java,jsp,Java,Jsp,我是一个Java的新手/业余程序员,我正在编写一些代码来帮助我添加记录、搜索和更新我广泛的电影收藏数据库。我已经编写了使用JSP添加和搜索记录的代码,效果很好。但是,我在更新记录的代码方面遇到了问题。我的JSP中出现以下错误,它似乎引用了我使用的response.sendRedirect()方法: org.apache.jasper.jaspereException:处理时发生异常 第63行的JSP页面/updateRecord.JSP 63:response.sendRedirect(“up

我是一个Java的新手/业余程序员,我正在编写一些代码来帮助我添加记录、搜索和更新我广泛的电影收藏数据库。我已经编写了使用JSP添加和搜索记录的代码,效果很好。但是,我在更新记录的代码方面遇到了问题。我的JSP中出现以下错误,它似乎引用了我使用的
response.sendRedirect()
方法:


org.apache.jasper.jaspereException:处理时发生异常 第63行的JSP页面/updateRecord.JSP

63:response.sendRedirect(“updaterecordsuccess.html”)


问题是,除了sql更新字符串外,我在另一个JSP中使用了基本相同的代码,并且运行良好。下面是给出错误的JSP页面的完整代码。
response.sendRedirect
方法位于代码的最后一行。我想我已经检查了所有的东西,但是我想不出来

 <%@ page contentType="text/html; charset=UTF-8" language="java" import="java.sql.*"    import="java.text.ParseException" import="java.text.SimpleDateFormat" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%
  Connection conn = null;

  Class.forName("com.mysql.jdbc.Driver").newInstance();
  conn = DriverManager.getConnection("jdbc:mysql://localhost/VideoDB?  user=user&password=password");

  PreparedStatement psUpdateRecord=null;
  String sqlUpdateRecord=null;


  String title=request.getParameter("title");
  String sDateVwd=request.getParameter("sDateVwd");
  int rating=Integer.parseInt(request.getParameter("rating"));
  String comments=request.getParameter("comments");

  try {

        java.util.Date utilDateVwd = new SimpleDateFormat("dd MMM   yyyy").parse(sDateVwd);
        java.sql.Date sqlDateVwd = new java.sql.Date(utilDateVwd.getTime());

    try {

     sqlUpdateRecord="UPDATE vidtb SET date_vwd = ?, rating = ?, comments = ? WHERE  title = ?";
     psUpdateRecord=conn.prepareStatement(sqlUpdateRecord);
     psUpdateRecord.setDate(1,sqlDateVwd);
     psUpdateRecord.setInt(2,rating);
     psUpdateRecord.setString(3,comments);
     psUpdateRecord.setString(4,title);       
     psUpdateRecord.executeUpdate();

      } finally {
    }

  } 
  catch (ParseException e) {
    e.printStackTrace();
  }

  catch(Exception e)
  {
      response.sendRedirect("rateRecord.jsp");//// On error it will send back to   rateRecord.jsp page
  }

    try{
      if(psUpdateRecord!=null)
      {
       psUpdateRecord.close();
      }

      if(conn!=null)
      {
       conn.close();
      }
    }
    catch(Exception e)
    {
      e.printStackTrace(); 
    }

response.sendRedirect("updaterecordsuccess.html");

%>


我的坏!我在家里随意地在另一台电脑上工作,决定尝试更新数据库中的一条记录,结果成功了。我猜我另一台计算机上的浏览器正在缓存坏结果。所以代码都很好。无论如何,感谢您的建议。

了解servlet和MVC模式。JSP应该生成标记并使用JSTL、EL和其他自定义标记,但不使用Java代码。您拥有的代码应该在servlet中。