我有一个如下的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>
在这里,我想用接收到的非空值更新我的数据库表,并且另一列不应更新为空,因为该列可能会在其他时间更新。但是,它显示的是一个空白页面,而不是任何查询字符串,请告诉我如何显示该查询字符串。
谢谢