Пример #1
0
 /**
  * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
  *
  * @param request servlet request
  * @param response servlet response
  * @throws ServletException if a servlet-specific error occurs
  * @throws IOException if an I/O error occurs
  */
 protected void processRequest(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   response.setContentType("text/html;charset=UTF-8");
   String title = request.getParameter("title");
   HttpSession session = request.getSession();
   String uid = (String) session.getAttribute("username");
   DBCommand commander = new DBCommand();
   commander.deleteFromLibrary(title, uid);
   RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/viewprofile.jsp");
   dispatcher.forward(request, response);
 }
Пример #2
0
 /**
  * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
  *
  * @param request servlet request
  * @param response servlet response
  * @throws ServletException if a servlet-specific error occurs
  * @throws IOException if an I/O error occurs
  */
 protected void processRequest(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   response.setContentType("text/html;charset=UTF-8");
   HttpSession session = request.getSession(true); // get the httpsession
   String uid = (String) session.getAttribute("username");
   DBCommand commander = new DBCommand();
   String[] details = commander.detailUser(uid);
   try (PrintWriter out = response.getWriter()) {
     /* TODO output your page here. You may use following sample code. */
     out.println("<!DOCTYPE html>");
     out.println("<html>");
     out.println("<head>");
     out.println("<title>" + uid + "'s Profile</title>");
     out.println("</head>");
     out.println("<body>");
     out.println("<h1>" + uid + "'s Profile Page</h1>");
     out.println("<p>Username: "******"</p>");
     out.println("<p>Full name: " + details[1] + "</p>");
     out.println("<p>Email: " + details[4] + "</p>");
     out.println("</body>");
     out.println("</html>");
   }
 }
Пример #3
0
 public static String[] getDetails(String uid) {
   DBCommand commander = new DBCommand();
   return commander.detailUser(uid);
 }
Пример #4
0
  public static String[][] getLibrary(String uid) {
    DBCommand commander = new DBCommand();

    return commander.retrieveLibrary(uid);
  }