servlet中的if判断无法完成
程序主要是学校的作业,
但是在servlet中 if判断语句只能执行 true的部分(用于页面的跳转), false的就无法执行(用于执行sql的添加语句)
我认为是逻辑上的问题 主要是 这一句 u=ud.finduserBynumber(number);放置的问题
package servlet;
import
java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import
javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import Dao.userDao;
import VO.user;
public class zhuce extends HttpServlet {
/**
* Constructor of the object.
*/
public zhuce() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* 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 {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out
.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
out.println(" <BODY>");
out.print(" This is ");
out.print(this.getClass());
out.println(", using the GET method");
out.println(" </BODY>");
out.println("</HTML>");
out.flush();
out.close();
doPost(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 {
request.setCharacterEncoding("GBK");
response.setCharacterEncoding("GBK");
response.setContentType("text/html");
String number=request.getParameter("number");
String password=request.getParameter("password");
String username=request.getParameter("username");
String name=request.getParameter("name");
String sex=request.getParameter("sex");
String age=request.getParameter("age");
String ldentitycard=request.getParameter("ldentitycard");
///////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
问题区域
/////////////////////////////////////
////////////////////////