我的jsp如下。更新基于jsp输入的数据库
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<form name="a" action="abc.jsp" method="post">
<input type="abc" id="abc" name="abc">
<input type="def" id="def" name="def"></form>
</body>
</html>
and the jsp that it is redirected is as below
<%@include file="DBCon.jsp" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%try
{
int s;
String a=request.getParameter("a");
String b=request.getParameter("b");
String c=request.getParameter("Ship_ID");
ps=con.prepareStatement("select TSI_QUERY,TSI_R,TSI_C,SI_QUERY,SI_R, SI_C from topical");
rs=ps.executeQuery();
if(rs.next()){
if(rs.getString("TSI_Query")==null && rs.getString("SI_Query")!=null)
{
String p="update topical set SI_Query='"+a+"', SI_R='x',SI_C='y' where Job_ID='"+c+"'";
System.out.print(p);
/*ps1=con.prepareStatement("update topical set TSI_Query=?, TSI_R=?,TSI_C=?");
ps1.setString(1, a);
ps1.setString(2, "x");
ps1.setString(3, "y");
s=ps1.executeUpdate();
if(s!=0){
String redirectURL= "a.jsp";
response.sendRedirect(redirectURL);
}*/
}
else if(rs.getString("SI_Query")==null && rs.getString("TSI_Query")!=null)
{
String p="update topical set SI_Query='"+b+"', SI_R='x',SI_C='y'where Job_ID='"+c+"'";
System.out.print(p);
/*ps1=con.prepareStatement("update topical set SI_Query=?, SI_R=?,SI_C=?");
ps1.setString(1, b);
ps1.setString(2, "x");
ps1.setString(3, "y");
s=ps1.executeUpdate();
if(s!=0){
String redirectURL= "a.jsp";
response.sendRedirect(redirectURL);}*/
}
else if(rs.getString("SI_Query")==null && rs.getString("TSI_Query")==null){
if(a==null && b!=null)
{
String p="update topical set TSI_Query='"+a+"', TSI_R='x',TSI_C='y'where Job_ID='"+c+"'";
/* ps1=con.prepareStatement("update topical set TSI_Query=?, TSI_R=?,TSI_C=?");
ps1.setString(1, a);
ps1.setString(2, "x");
ps1.setString(3, "y");
s=ps1.executeUpdate();
if(s!=0){
String redirectURL= "a.jsp";
response.sendRedirect(redirectURL);
}
*/ }
else if(b==null && a!=null){
String p="update topical set SI_Query='"+b+"', SI_R='x',SI_C='y'where Job_ID='"+c+"'";
System.out.print(p);
/*
ps1=con.prepareStatement("update topical set SI_Query=?, SI_R=?,SI_C=?");
ps1.setString(1, b);
ps1.setString(2, "x");
ps1.setString(3, "y");
s=ps1.executeUpdate();
if(s!=0){
String redirectURL= "a.jsp";
response.sendRedirect(redirectURL);
}*/
}
}
}
}
catch(Exception e)
{
out.println(e);
}
%>
</body>
</html>
在这里,我想收到的非空值和其他列不应该被更新null作为此列可能会更新一些其他的时间来更新我的数据库表。但是,它显示的是一个空白页面,而不是任何查询字符串,请让我知道如何获取显示的查询字符串。
感谢
阅读常见问题解答http://stackoverflow.com/faq关于如何提出问题并返回更多详细信息。 – 2013-03-08 13:05:05