cours0708/workspace/webapps/WEB-INF/classes/ServletController.java

55 lines
1.8 KiB
Java
Raw Normal View History

2008-11-25 21:11:16 +00:00
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.utilisateur;
/**
* * 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();
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);
utilisateur user = new utilisateur();
user.setId(identifiant);
requete.setAttribute("monUtilisateur", user);
rd.forward(requete,reponse);
// TODO Auto-generated method stub
}
}