package org.usi2011; import java.io.IOException; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.Map; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Servlet implementation class User */ public class User extends HttpServlet { private static final long serialVersionUID = 1L; private Connection connection; /** * @see HttpServlet#HttpServlet() */ public User() { super(); connection = Database.getConnection(); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { String firstname = request.getParameter("firstname"); String lastname = request.getParameter("lastname"); String mail = request.getParameter("mail"); String password = request.getParameter("password"); System.out.println(firstname); System.out.println(lastname); System.out.println(mail); System.out.println(password); String query = "INSERT INTO game(firstname, lastname, mail) VALUES ('"+firstname+"', '"+lastname+"', '"+mail+"', '"+password+"')"; Statement statement = connection.createStatement(); ResultSet resultset = statement.executeQuery(query); response.setStatus(response.SC_CREATED); } catch (SQLException e) { System.out.println(e.getMessage()); response.sendError(400); } } }