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);
    private Map<String, User> users = new HashMap<>();
//    private Storage storage = new Storage();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html");
        PrintWriter writer = new PrintWriter(resp.getOutputStream());
        writer.append("Hello user!");
        writer.flush();
    }
/*
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html");
        String login = request.getParameter("login");
        PrintWriter writer = new PrintWriter(response.getOutputStream());
        writer.append("Login: " + login);
        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);
    }
*/
}

@@ -313,24 +313,43 @@
 rintWriter;%0A
+import java.sql.*;%0A
 import java.
@@ -578,421 +578,8 @@
 s);%0A
-    private Map%3CString, User%3E users = new HashMap%3C%3E();%0A//    private Storage storage = new Storage();%0A%0A    @Override%0A    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException %7B%0A        resp.setContentType(%22text/html%22);%0A        PrintWriter writer = new PrintWriter(resp.getOutputStream());%0A        writer.append(%22Hello user!%22);%0A        writer.flush();%0A    %7D%0A/*
 %0A   
@@ -761,62 +761,8 @@
 %22);%0A
-        String login = request.getParameter(%22login%22);%0A
     
@@ -843,41 +843,890 @@
     
-writer.append(%22Login: %22 + login);
+try %7B%0A            Class.forName(%22org.postgresql.Driver%22);%0A            Settings settings = Settings.getInstance();%0A            Connection connection = DriverManager.getConnection(%0A                    %22jdbc:postgresql://127.0.0.1:5432/sqlite%22,%0A                    %22anton%22,%0A                    %22password%22);%0A            PreparedStatement ps = connection.prepareStatement(%22SELECT * FROM users%22);%0A            Statement statement = connection.createStatement();%0A            ResultSet rs = statement.executeQuery(%22SELECT * FROM users%22);%0A            Map%3CString, User%3E users = new HashMap%3C%3E();%0A            while (rs.next()) %7B%0A                users.put(rs.getString(%22login%22), new User(rs.getString(%22name%22), rs.getString(%22email%22), rs.getString(%22createDate%22)));%0A            %7D%0A            writer.append(users.toString());%0A        %7D catch (Exception e) %7B%0A            e.printStackTrace();%0A        %7D
 %0A   
@@ -2900,10 +2900,11 @@
    %7D%0A*/%0A
+%0A
 %7D%0A

Create connection between servlet and jdbc. In doGet method.