[Java] 实现预约功能 →→→→→进入此内容的聊天室

来自 , 2021-03-05, 写在 Java, 查看 159 次.
URL http://www.code666.cn/view/980ecd05
  1. package com.hospital.servlet;
  2.  
  3. import java.io.IOException;
  4. import java.io.PrintWriter;
  5. import java.sql.Connection;
  6. import java.sql.ResultSet;
  7. import java.sql.SQLException;
  8. import java.sql.Statement;
  9. import java.util.Map;
  10.  
  11. import javax.servlet.RequestDispatcher;
  12. import javax.servlet.ServletException;
  13. import javax.servlet.http.HttpServlet;
  14. import javax.servlet.http.HttpServletRequest;
  15. import javax.servlet.http.HttpServletResponse;
  16. import javax.servlet.http.HttpSession;
  17.  
  18. import com.hospital.constant.MyConstant;
  19. import com.hospital.model.User;
  20. import com.hospital.util.DaoUtil;
  21.  
  22. public class Login extends HttpServlet {
  23.  
  24.  
  25.     /**
  26.      * Destruction of the servlet. <br>
  27.      */
  28.     public void destroy() {
  29.         super.destroy(); // Just puts "destroy" string in log
  30.         // Put your code here
  31.     }
  32.  
  33.     /**
  34.      * The doPost method of the servlet. <br>
  35.      *
  36.      * This method is called when a form has its tag value method equals to post.
  37.      *
  38.      * @param request the request send by the client to the server
  39.      * @param response the response send by the server to the client
  40.      * @throws ServletException if an error occurred
  41.      * @throws IOException if an error occurred
  42.      */
  43.     public void doPost(HttpServletRequest request, HttpServletResponse response)
  44.             throws ServletException, IOException {
  45.         response.setContentType("text/html;charset=utf-8");
  46.         request.setCharacterEncoding("utf-8");
  47.         PrintWriter out = response.getWriter();
  48.        
  49.         String username=request.getParameter("username");
  50.         String password=request.getParameter("password");
  51.        
  52.         if (username.equals(MyConstant.userName)){
  53.             if (password.equals(MyConstant.password)){
  54.                 RequestDispatcher requestDispatcher = request.getRequestDispatcher("../mainFram.jsp");
  55.                 requestDispatcher.forward(request, response);
  56.                
  57.             }
  58.             else {
  59.                 PrintWriter pw = response.getWriter();
  60.                 pw.println("<script>alert('您输入的密码有误!')</script>");
  61.                 pw.println("<script>window.location.href='../Login.jsp';</script>");
  62.                 pw.flush();
  63.                 pw.close();
  64.             }
  65.         }
  66.         else {
  67.             PrintWriter pw = response.getWriter();
  68.             pw.println("<script>alert('您输入的帐号有误!')</script>");
  69.             pw.println("<script>window.location.href='../Login.jsp';</script>");
  70.             pw.flush();
  71.             pw.close();
  72.         }
  73.        
  74.            
  75.        
  76.        
  77.        
  78.  
  79.     }
  80.  
  81.     /**
  82.      * Initialization of the servlet. <br>
  83.      *
  84.      * @throws ServletException if an error occurs
  85.      */
  86.     public void init() throws ServletException {
  87.         // Put your code here
  88.     }
  89.  
  90. }
  91.  

回复 "实现预约功能"

这儿你可以回复上面这条便签

captcha