import java.io.IOException; import java.io.PrintWriter; import javax.servlet.RequestDispatcher; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import MesHaricots.MonUtilisateur; /** * * Servlet implementation class for Servlet: ServTest * * * */ public class ServletController extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet { static final long serialVersionUID = 1L; /* (non-Java-doc) * * @see javax.servlet.http.HttpServlet#HttpServlet() * */ public ServletController() { super(); } /* (non-Java-doc) * * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) * */ protected void doGet(HttpServletRequest requete, HttpServletResponse reponse) throws ServletException, IOException { String jspPage = "/vues/loginForm.jsp"; ServletContext sc = getServletContext(); jspPage = sc.getServletContext().getContextPath(); RequestDispatcher rd = sc.getRequestDispatcher(jspPage); rd.forward(requete,reponse); } /* (non-Java-doc) * * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) * */ protected void doPost(HttpServletRequest requete, HttpServletResponse reponse) throws ServletException, IOException { String identifiant = requete.getParameter("id"); String jspPage = "/vues/salut.jsp"; ServletContext sc = getServletContext(); RequestDispatcher rd = sc.getRequestDispatcher(jspPage); MonUtilisateur user = new MonUtilisateur(); user.setId(identifiant); requete.setAttribute("monUtilisateur", user); rd.forward(requete,reponse); // TODO Auto-generated method stub } }