KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mc > formgenerator > servlets > bonita > ServletAccueil


1 /*
2  * Created on 3 mai 2004
3  *
4  * To change the template for this generated file go to
5  * Window>Preferences>Java>Code Generation>Code and Comments
6  */

7
8 package mc.formgenerator.servlets.bonita;
9
10 import java.io.File JavaDoc;
11 import java.io.IOException JavaDoc;
12
13 import javax.servlet.http.*;
14
15 /**
16  * It is the servlet which allows the posting of the projects modeles to display.
17  * It asks to the Modele class to obtain information,
18  * and redirects the result on the JSP page so that posting is not with the treatment.
19  * @author delfourr
20  */

21 public class ServletAccueil extends HttpServlet {
22
23
24
25
26     /**
27      * @throws IOException
28      */

29     public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException JavaDoc {
30         
31         //Create the modele corresponding to this controller
32
ModeleAccueil accueil = new ModeleAccueil();
33         
34         //Create the repository facade corresponding to this controller
35
//System.out.println("REPOSITORY FACADE FILE: " + getServletConfig().getServletContext().getRealPath("") + File.separator + "web" + File.separator+ "repository.xml");
36
RepositoryFacade repositoryFacade = new RepositoryFacade(getServletConfig().getServletContext().getRealPath("") + File.separator + "web" + File.separator+ "repository.xml");
37                 
38         //Get the session of the user.
39
HttpSession session = req.getSession(true);
40
41         //Save in the session the modele which has the information to display.
42
session.setAttribute("modeleAccueil",accueil);
43         
44         //Save in the session the repository facade.
45
session.setAttribute("repositoryFacade",repositoryFacade);
46         
47         try{
48             //Asks to the modele to do its work.
49
accueil.process();
50         
51             String JavaDoc url = new String JavaDoc(req.getRequestURL());
52             
53             //The request is redirected on the JSP page so that it builds the answer for the user.
54
this.getServletContext().getRequestDispatcher("/web/jsp/accueil.jsp").forward(req,res);
55
56         }
57         catch(Exception JavaDoc e){
58             e.printStackTrace();
59             res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
60         }
61     }
62
63
64
65 }
66
Popular Tags