package Servlet;
import java.io.IOException;
import javax.mail.MessagingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import beans.User;
import DAO.JDBCUserDAO;
import Interface.UserDAOInterface;
import utility.SendMail;
/**
* Servlet implementation class Souscription
*/
public class Souscription extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public Souscription() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
SendMail t = new SendMail();
UserDAOInterface userDAO = new JDBCUserDAO();
User user=(User)request.getSession().getAttribute("user");
String code =userDAO.createAbonnement(user.getLogin(),request.getParameter("duree"));
try {
String content="Merci de vous �tres abonn�s sur notre site de jeux en ligne" +
"<br>"+user.getLogin()+"Voici votre code d'acc�s pour "+request.getParameter("duree")+" mois de fun ! :" +
"<br> Code :"+code;
t.run(request,"Souscription � un abonnement de "+request.getParameter("duree")+" mois",content,user.getEmail());
} catch (MessagingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
request.getRequestDispatcher("code.jsp").forward(request, response);
return;
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}
}