package ru.aserdyuchenko.crudServlet;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

/**
 * @author Anton Serdyuchenko. anton415@gmail.com
 */
public class UsersServlet extends HttpServlet {
    private static final Logger log = LoggerFactory.getLogger(UsersServlet.class);

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html");
        PrintWriter writer = new PrintWriter(response.getOutputStream());
        try {
            Class.forName("org.postgresql.Driver");
            Storage storage = new Storage();
            Map<String, User> users = storage.get();
            writer.append(users.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
        writer.flush();
    }
/*
    @Override
    protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html");
        try {
            this.storage.add(request.getParameter("login"), request.getParameter("name"), request.getParameter("email"), request.getParameter("createDate"));
        } catch (SQLException e) {
            e.printStackTrace();
        }
        doGet(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html");
        this.users.put(request.getParameter("login"), new User(request.getParameter("name"), request.getParameter("email"), request.getParameter("createDate")));
        doGet(request, response);
    }

    @Override
    protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html");
        this.users.remove(request.getParameter("login"));
        doGet(request, response);
    }
*/

}

@@ -333,20 +333,24 @@
 ava.
-util.HashMap
+sql.SQLException
 ;%0Aim
@@ -1130,18 +1130,17 @@
 ;%0A    %7D%0A
-/*
+%0A
 %0A    @Ov
@@ -1340,21 +1340,113 @@
         
-this.
+Class.forName(%22org.postgresql.Driver%22);%0A            Storage storage = new Storage();%0A            
 storage.
@@ -1638,32 +1638,97 @@
 ntStackTrace();%0A
+        %7D catch (Exception e) %7B%0A            e.printStackTrace();%0A
         %7D%0A      
@@ -1753,32 +1753,34 @@
 esponse);%0A    %7D%0A
+/*
 %0A    @Override%0A 

Add doPut method.