package servlet;
import org.apache.commons.lang3.StringEscapeUtils;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import business.Utilisateur;
import dao.DaoUtilisateur;
public class S_UserSubscribe extends HttpServlet {
private static final long serialVersionUID = 1L;
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("html");
String mail = request.getParameter("mail");
String pseudo = StringEscapeUtils.escapeHtml4(request.getParameter("pseudo"));
String password = request.getParameter("password");
Utilisateur utilisateur = DaoUtilisateur.subscribe(mail, pseudo, password);
if(utilisateur != null)
request.getSession().setAttribute("utilisateur", utilisateur);
else
response.setStatus(599);
}
}