public static void main(String[] args) throws Exception { DBService dbService = new DBService(); dbService.printConnectInfo(); try { long userId = dbService.addUser("tully", "querty"); System.out.println("Added user id: " + userId); UsersDataSet dataSet = dbService.getUser(userId); System.out.println("User data set: " + dataSet); } catch (DBException e) { e.printStackTrace(); } createServlets(dbService); }
public static void main(String[] args) { DBService dbService = new DBService(); dbService.printConnectInfo(); ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS); // context.setContextPath("/"); // context.addServlet(new ServletHolder(new MainServlet()), "/"); context.addServlet(new ServletHolder(new SignUpServlet(dbService)), "/signup"); context.addServlet(new ServletHolder(new SignInServlet(dbService)), "/signin"); ResourceHandler resource_handler = new ResourceHandler(); resource_handler.setResourceBase("./public_html"); HandlerList handlers = new HandlerList(); handlers.setHandlers(new Handler[] {resource_handler, context}); Server server = new Server(8080); server.setHandler(handlers); try { long userId = dbService.addUser("test1", "test1"); System.out.println("Added user id: " + userId); UsersDataSet dataSet = dbService.getUser(userId); System.out.println("User data set: " + dataSet); // dbService.cleanUp(); } catch (DBException e) { e.printStackTrace(); } try { server.start(); System.out.println("Server started"); server.join(); } catch (Exception e) { e.printStackTrace(); } }