Example #1
0
  /**
   * Handles the HTTP <code>POST</code> method.
   *
   * @param request servlet request
   * @param response servlet response
   * @throws ServletException if a servlet-specific error occurs
   * @throws IOException if an I/O error occurs
   */
  @Override
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    String[] values = new String[7];

    values[0] = request.getParameter("username");
    values[1] = request.getParameter("password");
    values[2] = request.getParameter("first_name");
    values[3] = request.getParameter("last_name");
    values[4] = request.getParameter("email");
    values[5] = request.getParameter("address");
    values[6] = "Please modify your about page!";
    for (int i = 2; i < 7; i++) {
      if (values[i].equals("")) {
        values[i] = "";
      }
    }
    if (values[0].equals("") || values[1].equals("")) {
      displayError("Username and password are mandatory", response);
    }
    User us = new User();
    us.setCluster(cluster);
    if (us.checkUserExist(values[0])) {
      displayError("Username already taken. Please choose another one", response);
    }
    us.RegisterUser(values[0], values[1], values[2], values[3], values[4], values[5], values[6]);
    String path = request.getContextPath();
    response.sendRedirect(path + "/Login");
  }
Example #2
0
  /**
   * Handles the HTTP <code>POST</code> method.
   *
   * @param request servlet request
   * @param response servlet response
   * @throws ServletException if a servlet-specific error occurs
   * @throws IOException if an I/O error occurs
   */
  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    User us = new User();
    us.setCluster(cluster);
    HttpSession session = request.getSession();
    LoggedIn lg = new LoggedIn();
    lg.setLoggedout();
    lg.setUsername(null);
    session.setAttribute("LoggedIn", lg);
    response.sendRedirect("index.jsp");
  }
Example #3
0
  private void DisplayImageList(
      String User, HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    User user = new User();
    user.setCluster(cluster);
    if (user.checkUser(User)) {
      PicModel tm = new PicModel();
      tm.setCluster(cluster);
      LinkedList<Pic> lsPics = tm.getPicsForUser(User);
      request.setAttribute("Pics", lsPics);
      request.setAttribute("user", User);

      UUID pp = tm.getProfilePic(User);
      request.setAttribute("profilePic", pp);

      RequestDispatcher rd = request.getRequestDispatcher("/UsersPics.jsp");
      rd.forward(request, response);
    } else {
      response.sendError(404);
    }
  }