public void login(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    User user = new User();
    user.setUname(request.getParameter("loginName").trim());
    user.setUpasswd(request.getParameter("password").trim());

    UserDao userDao = new UserDao();
    user = userDao.userLogin(user);
    HttpSession session = request.getSession();
    if (user == null) {
      request.setAttribute("error", "用户名或密码错误!");
      request.getRequestDispatcher("loginUI.jsp").forward(request, response);
      return;
    }
    session.setAttribute("user", user);
    request.getRequestDispatcher("index.jsp").forward(request, response);
  }
Exemple #2
0
  public static void main(String[] args) {

    StringBuilder sb =
        new StringBuilder(
            "C:"
                + File.separator
                + "DEV"
                + File.separator
                + "apache-tomcat-7.0.27"
                + File.separator
                + "wtpwebapps"
                + File.separator
                + "ShareServer"
                + File.separator
                + "upload20120705135932017.prop");
    String path =
        sb.subSequence(sb.indexOf(File.separator + "ShareServer"), sb.length()).toString();
    System.out.println(path);

    /*
    for (int i = 0; i <100; i++) {
    	Thread t = new Thread(new Runnable() {
    		@Override
    		public void run() {
    			int port = PortUtil.getPort();
    			//FileUploadServerUtil.getInstance().doService(port, "R:"+port+".txt");
    			FileUploadClient client = new FileUploadClient("127.0.0.1",port);
    			client.doUpload("R:1.txt");
    		}
    	});
    	t.start();
    	*/
    UserDao userDao = new UserDao();
    String xmpp = userDao.getXMPPName(2);
    System.out.println(xmpp);
  }