【问题标题】:JSP redirects to another page instead of next pageJSP 重定向到另一个页面而不是下一页
【发布时间】:2014-05-17 19:47:55
【问题描述】:

在数据库中插入值然后重定向到另一个jsp页面?但实际上没有在数据库中插入值它重定向到下一个jsp页面 int i= ps.executeUpdate();

if(i!=0) {     
    session.setAttribute("userid", user);
    response.sendRedirect("admin.jsp");
    out.print("<font size='6',color='aqua'>Welcome Admin page</font>");
} else {
    response.sendRedirect("adminlogin.jsp");
}

【问题讨论】:

  • 我们无法理解您的问题。尝试更好地编辑和解释

标签: java jsp


【解决方案1】:
int i=ps.executeUpdate("update tablename set col1='sss' where col2='hhh'");
      //i is 1 if any one row is updated that is if any one row matches the condition
        //i is 0 otherwise
        if(i==1)
        {
        response.sendRedirect("page1.jsp");
        }
        else
        {
        response.sendRedirect("page2.jsp");
        }

【讨论】:

    猜你喜欢
    • 2018-03-15
    • 1970-01-01
    • 1970-01-01
    • 2014-06-24
    • 2013-09-05
    • 2017-06-05
    • 1970-01-01
    • 2017-08-10
    • 2012-12-10
    相关资源
    最近更新 更多