Bonjour à tous,
Voilà mon soucis, je suis DBA et on me demande de migrer la BDD d'une (vieille) application java. Etant curieux de nature, et afin de controler que tout se passe correctement, j'ai demandé les sources de l'application.
J'ai donc recu 3 dossiers composés comme suit :
J'ai donc créé sous Eclipse un projet tomcat, et j'ai réglé les différentes erreurs que j'ai pu y trouver.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83 /maquette /dossiers xxx.htm /images xxx.jpg /referentiels xxx.htm /style xxx.css xxx.htm xxx.htm xxx.htm /src annuaire.properties ares.hbm.xml hibernate.cfg.xml log4j.dtd log4j.xml MessageTessources.properties /ares /factory xxx.java /metier xxx.java /servlet ServletControler.java /struts xxx.java /util /javascript xxx.js xxx.java /webapp /jsp /dossier xxx.jsp /javascript xxx.js /referentiels xxx.jsp xxx.jsp /static-content /images xxx.jpg /import xxx.xls /style xxx.css xxx.htm /WEB-INF /classes annuaire.properties ares.hbm.xml hibernate.cfg.xml log4j.dtd log4j.xml MessageTessources.properties /ares /factory xxx.java /metier xxx.java /servlet ServletControler.java /struts xxx.java /util /javascript xxx.js xxx.java /lib xxx.jar struts-bean.tld struts-config.xml struts-html.tld struts-layout.tld struts-logic.tld struts-nested.tld validation.xml validation-rules.xml web.xml
Lorsque je démarre mon tomcat, et que je vais dans tomcat manager, je vois bien mon application (ares) qui y apparait et est démarrée.
Mais lorsque je lance un navigateur web sous Eclipse, et que j'entre dans l'url :
L'URL est modifiée et deviens
Avec une belle erreur 404...
J'ai une erreur dans ma log Tomcat :
Je vous met des fichiers qui me paraissent important afin de réussir à lancer cette application..20 oct. 2011 10:20:14 org.apache.catalina.core.ApplicationContext log
INFO: La servlet strutsServlet est marqué comme indisponible
20 oct. 2011 10:20:14 org.apache.catalina.core.StandardContext loadOnStartup
GRAVE: La servlet /ares a généré une exception "load()"
java.lang.ClassCastException: org.apache.struts.action.ActionServlet cannot be cast to javax.servlet.Servlet
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1104)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4042)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4348)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
web.xml
Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85 <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd"> <web-app> <description>ARES</description> <servlet> <servlet-name>servletControleur</servlet-name> <servlet-class>ares.servlet.ServletControleur</servlet-class> <init-param><param-name>login</param-name><param-value>/jsp/login.jsp</param-value></init-param> <init-param><param-name>accueil_gauche</param-name><param-value>/jsp/accueil_gauche.jsp</param-value></init-param> <init-param><param-name>apropos</param-name><param-value>/jsp/apropos.jsp</param-value></init-param> <init-param><param-name>import_primes</param-name><param-value>/jsp/referentiels/import_primes.jsp</param-value></init-param> <init-param><param-name>import_baremes</param-name><param-value>/jsp/referentiels/import_baremes.jsp</param-value></init-param> </servlet> <servlet> <servlet-name>strutsServlet</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param><param-name>config</param-name><param-value>/WEB-INF/struts-config.xml</param-value></init-param> <init-param><param-name>debug</param-name><param-value>1</param-value></init-param> <init-param><param-name>detail</param-name><param-value>1</param-value></init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>servletControleur</servlet-name> <url-pattern>/servletControleur</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>strutsServlet</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <session-config> <session-timeout>45</session-timeout> </session-config> <welcome-file-list> <welcome-file>static-content/index.htm</welcome-file> </welcome-file-list> <taglib> <taglib-uri>struts-bean.tld</taglib-uri> <taglib-location>/WEB-INF/struts-bean.tld</taglib-location> </taglib> <taglib> <taglib-uri>struts-html.tld</taglib-uri> <taglib-location>/WEB-INF/struts-html.tld</taglib-location> </taglib> <taglib> <taglib-uri>struts-layout.tld</taglib-uri> <taglib-location>/WEB-INF/struts-layout.tld</taglib-location> </taglib> <taglib> <taglib-uri>struts-logic.tld</taglib-uri> <taglib-location>/WEB-INF/struts-logic.tld</taglib-location> </taglib> <taglib> <taglib-uri>struts-nested.tld</taglib-uri> <taglib-location>/WEB-INF/struts-nested.tld</taglib-location> </taglib> </web-app>
struts-config.xml
Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352 <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd"> <struts-config> <data-sources /> <form-beans> <form-bean name="agent" type="ares.metier.Agent" /> <form-bean name="bareme" type="ares.metier.Bareme" /> <form-bean name="carriere" type="ares.metier.Carriere" /> <form-bean name="motif" type="ares.metier.Motif" /> <form-bean name="parametre" type="ares.metier.Parametre" /> <form-bean name="prime" type="ares.metier.Prime" /> <form-bean name="utilisateur" type="ares.metier.Utilisateur" /> </form-beans> <global-exceptions /> <global-forwards /> <action-mappings> <action path="/controlerLogin" name="utilisateur" type="ares.struts.UtilisateurAction" scope="session" validate="true" input="/jsp/login.jsp"> <forward name="success" path="/static-content/accueil.htm" /> <forward name="failure" path="/jsp/login.jsp" /> </action> <action path="/parametres" name="parametre" type="ares.struts.ParametreAction" scope="session" validate="false" input="/jsp/referentiels/parametres.jsp"> <forward name="success" path="/jsp/referentiels/parametres.jsp" /> <forward name="reconnexion" path="/jsp/reconnexion.jsp" /> </action> <action path="/validerParametres" name="parametre" type="ares.struts.ParametreAction" scope="session" validate="true" input="/jsp/referentiels/parametres.jsp"> <forward name="success" path="/jsp/referentiels/parametres.jsp" /> <forward name="failure" path="/jsp/referentiels/parametres.jsp" /> <forward name="reconnexion" path="/jsp/reconnexion.jsp" /> </action> <action path="/baremes" name="bareme" type="ares.struts.BaremeAction" scope="session" validate="false" input="/jsp/referentiels/baremes.jsp"> <forward name="success" path="/jsp/referentiels/baremes.jsp" /> <forward name="reconnexion" path="/jsp/reconnexion.jsp" /> </action> <action path="/gestionBareme" name="bareme" type="ares.struts.BaremeAction" scope="session" validate="false" input="/jsp/referentiels/baremes.jsp"> <forward name="success" path="/jsp/referentiels/gestion_bareme.jsp" /> <forward name="failure" path="/jsp/referentiels/baremes.jsp" /> <forward name="reconnexion" path="/jsp/reconnexion.jsp" /> </action> <action path="/validerBareme" name="bareme" type="ares.struts.BaremeAction" scope="session" validate="true" input="/jsp/referentiels/gestion_bareme.jsp"> <forward name="success" path="/jsp/referentiels/baremes.jsp" /> <forward name="failure" path="/jsp/referentiels/gestion_bareme.jsp" /> <forward name="reconnexion" path="/jsp/reconnexion.jsp" /> </action> <action path="/importBaremes" name="bareme" type="ares.struts.ExcelAction" scope="session" validate="false" input="/jsp/referentiels/baremes.jsp"> <forward name="success" path="/jsp/referentiels/import_baremes.jsp" /> <forward name="reconnexion" path="/jsp/reconnexion.jsp" /> </action> <action path="/excelBaremes" name="bareme" type="ares.struts.ExcelAction" scope="session" validate="false" input="/jsp/referentiels/import_baremes.jsp"> <forward name="success" path="/jsp/referentiels/baremes.jsp" /> <forward name="failure" path="/jsp/referentiels/import_baremes.jsp" /> <forward name="reconnexion" path="/jsp/reconnexion.jsp" /> </action> <action path="/motifs" name="motif" type="ares.struts.MotifAction" scope="session" validate="false" input="/jsp/referentiels/motifs.jsp"> <forward name="success" path="/jsp/referentiels/motifs.jsp" /> <forward name="reconnexion" path="/jsp/reconnexion.jsp" /> </action> <action path="/gestionMotif" name="motif" type="ares.struts.MotifAction" scope="session" validate="false" input="/jsp/referentiels/motifs.jsp"> <forward name="success" path="/jsp/referentiels/gestion_motif.jsp" /> <forward name="failure" path="/jsp/referentiels/motifs.jsp" /> <forward name="reconnexion" path="/jsp/reconnexion.jsp" /> </action> <action path="/validerMotif" name="motif" type="ares.struts.MotifAction" scope="session" validate="true" input="/jsp/referentiels/gestion_motif.jsp"> <forward name="success" path="/jsp/referentiels/motifs.jsp" /> <forward name="failure" path="/jsp/referentiels/gestion_motif.jsp" /> <forward name="reconnexion" path="/jsp/reconnexion.jsp" /> </action> <action path="/primes" name="prime" type="ares.struts.PrimeAction" scope="session" validate="false" input="/jsp/referentiels/primes.jsp"> <forward name="success" path="/jsp/referentiels/primes.jsp" /> <forward name="reconnexion" path="/jsp/reconnexion.jsp" /> </action> <action path="/gestionPrime" name="prime" type="ares.struts.PrimeAction" scope="session" validate="false" input="/jsp/referentiels/primes.jsp"> <forward name="success" path="/jsp/referentiels/gestion_prime.jsp" /> <forward name="failure" path="/jsp/referentiels/primes.jsp" /> <forward name="reconnexion" path="/jsp/reconnexion.jsp" /> </action> <action path="/validerPrime" name="prime" type="ares.struts.PrimeAction" scope="session" validate="true" input="/jsp/referentiels/gestion_prime.jsp"> <forward name="success" path="/jsp/referentiels/primes.jsp" /> <forward name="failure" path="/jsp/referentiels/gestion_prime.jsp" /> <forward name="reconnexion" path="/jsp/reconnexion.jsp" /> </action> <action path="/importPrimes" name="prime" type="ares.struts.ExcelAction" scope="session" validate="false" input="/jsp/referentiels/primes.jsp"> <forward name="success" path="/jsp/referentiels/import_primes.jsp" /> <forward name="reconnexion" path="/jsp/reconnexion.jsp" /> </action> <action path="/excelPrimes" name="prime" type="ares.struts.ExcelAction" scope="session" validate="false" input="/jsp/referentiels/import_primes.jsp"> <forward name="success" path="/jsp/referentiels/primes.jsp" /> <forward name="failure" path="/jsp/referentiels/import_primes.jsp" /> <forward name="reconnexion" path="/jsp/reconnexion.jsp" /> </action> <action path="/creerDossier" name="agent" type="ares.struts.AgentAction" scope="session" validate="false" input="/jsp/dossiers/creer_dossier.jsp"> <forward name="success" path="/jsp/dossiers/creer_dossier.jsp" /> <forward name="reconnexion" path="/jsp/reconnexion.jsp" /> </action> <action path="/validerCreationDossier" name="agent" type="ares.struts.AgentAction" scope="session" validate="true" input="/jsp/dossiers/creer_dossier.jsp"> <forward name="success" path="/jsp/dossiers/creer_dossier.jsp" /> <forward name="failure" path="/jsp/dossiers/creer_dossier.jsp" /> <forward name="reconnexion" path="/jsp/reconnexion.jsp" /> </action> <action path="/rechercherContact" name="agent" type="ares.struts.AgentAction" scope="session" validate="false" input="/jsp/dossiers/creer_dossier.jsp"> <forward name="success" path="/jsp/dossiers/creer_dossier.jsp" /> <forward name="failure" path="/jsp/dossiers/creer_dossier.jsp" /> <forward name="reconnexion" path="/jsp/reconnexion.jsp" /> </action> <action path="/dossiers" name="agent" type="ares.struts.AgentAction" scope="session" validate="false" input="/jsp/dossiers/dossiers.jsp"> <forward name="success" path="/jsp/dossiers/dossiers.jsp" /> <forward name="reconnexion" path="/jsp/reconnexion.jsp" /> </action> <action path="/carrieres" name="carriere" type="ares.struts.CarriereAction" scope="session" validate="false" input="/jsp/dossiers/carrieres.jsp"> <forward name="success" path="/jsp/dossiers/carrieres.jsp" /> <forward name="reconnexion" path="/jsp/reconnexion.jsp" /> </action> <action path="/gestionCarriere" name="carriere" type="ares.struts.CarriereAction" scope="session" validate="false" input="/jsp/dossiers/carrieres.jsp"> <forward name="success" path="/jsp/dossiers/gestion_carriere.jsp" /> <forward name="reconnexion" path="/jsp/reconnexion.jsp" /> </action> <action path="/convertirEuros" name="carriere" type="ares.struts.CarriereAction" scope="session" validate="true" input="/jsp/dossiers/gestion_carriere.jsp"> <forward name="success" path="/jsp/dossiers/gestion_carriere.jsp" /> <forward name="failure" path="/jsp/dossiers/gestion_carriere.jsp" /> <forward name="reconnexion" path="/jsp/reconnexion.jsp" /> </action> <action path="/validerCarriere" name="carriere" type="ares.struts.CarriereAction" scope="session" validate="true" input="/jsp/dossiers/gestion_carriere.jsp"> <forward name="success" path="/jsp/dossiers/carrieres.jsp" /> <forward name="failure" path="/jsp/dossiers/gestion_carriere.jsp" /> <forward name="reconnexion" path="/jsp/reconnexion.jsp" /> </action> <action path="/gestionDossier" name="agent" type="ares.struts.AgentAction" scope="session" validate="false" input="/jsp/dossiers/dossiers.jsp"> <forward name="success" path="/jsp/dossiers/gestion_dossier.jsp" /> <forward name="failure" path="/jsp/dossiers/dossiers.jsp" /> <forward name="reconnexion" path="/jsp/reconnexion.jsp" /> </action> <action path="/validerDossier" name="agent" type="ares.struts.AgentAction" scope="session" validate="true" input="/jsp/dossiers/gestion_dossier.jsp"> <forward name="success" path="/jsp/dossiers/dossiers.jsp" /> <forward name="failure" path="/jsp/dossiers/gestion_dossier.jsp" /> <forward name="reconnexion" path="/jsp/reconnexion.jsp" /> </action> <action path="/editions" name="agent" type="ares.struts.EditionAction" scope="session" validate="false" input="/jsp/dossiers/editions.jsp"> <forward name="success" path="/jsp/dossiers/editions.jsp" /> <forward name="failure" path="/jsp/dossiers/editions.jsp" /> <forward name="reconnexion" path="/jsp/reconnexion.jsp" /> </action> <action path="/gererDelai" name="agent" type="ares.struts.AgentAction" scope="session" validate="false" input="/jsp/dossiers/gerer_delai.jsp"> <forward name="success" path="/jsp/dossiers/gerer_delai.jsp" /> <forward name="failure" path="/jsp/dossiers/gerer_delai.jsp" /> <forward name="reconnexion" path="/jsp/reconnexion.jsp" /> </action> <action path="/afficherContact" name="parametre" type="ares.struts.ParametreAction" scope="session" validate="false" input="/jsp/contact.jsp"> <forward name="success" path="/jsp/contact.jsp" /> <forward name="reconnexion" path="/jsp/reconnexion.jsp" /> </action> </action-mappings> <message-resources parameter="MessageResources" /> <plug-in className="org.apache.struts.validator.ValidatorPlugIn"> <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" /> </plug-in> </struts-config>
index.htm
Code htm : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 <html> <head> <title>ARES</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name="description" content="ARES" /> <meta name="keywords" content="ares" /> <meta http-equiv="refresh" content="0;URL=../servletControleur?page=login" /> </head> </html>
servletControleur.java
Code java : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217 /* * Nom du fichier : ServletControleur.java */ package ares.servlet; import java.io.File; import java.io.IOException; import java.util.HashMap; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Classe centralisant toutes les demandes de l'application */ public class ServletControleur extends HttpServlet { /** * Initialisation JSP : identification de l'utilisateur */ private String login; /** * Initialisation JSP : menu de l'application */ private String accueil_gauche; /** * Initialisation JSP : afficher les informations sur l'application */ private String apropos; /** * Initialisation JSP import primes */ private String import_primes; /** * Initialisation JSP import barèmes */ private String import_baremes; /** * repertoire racine de l'application */ public static String repRacine; /** * Path */ private String PATH_STATIC = "/static-content"; /** * Path des imports */ private String PATH_IMPORTS = "/static-content/imports/"; /** * Répertoire des imports */ private String REP_IMPORTS = "imports"; /** * Nom du fichier d'import des barèmes de cotisation */ private String XLS_BAREMES = "baremes.xls"; /** * Nom du fichier d'import des primes de résultat d'exploitation */ private String XLS_PRIMES = "primes.xls"; /** * Initialisation du logger */ public static Logger logger = (Logger) Logger.getLogger(ServletControleur.class.getName()); /** * Méthode qui initialise la servlet à partir du fichier web.xml * * @throws ServletException ServletException */ public void init() throws ServletException { try { login = getServletConfig().getInitParameter("login"); accueil_gauche = getServletConfig().getInitParameter("accueil_gauche"); apropos = getServletConfig().getInitParameter("apropos"); import_primes = getServletConfig().getInitParameter("import_primes"); import_baremes = getServletConfig().getInitParameter("import_baremes"); // récupération du répertoire racine de l'application repRacine = getServletContext().getRealPath(""); } catch (Exception exc) { // Affichage de l'erreur retournée par l'exception logger.error("Erreur dans la méthode init() : " + exc.getMessage()); } } /** * Méthode doGet de la servlet qui traite les demandes du navigateur client * * @param request requête envoyée par le client à la servlet * @param response réponse retournée par la servlet au client * @throws ServletException ServletException * @throws IOException IOException */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { // Récupération des paramètres envoyés par le client String page = request.getParameter("page"); // Déclaration des delegate // récupération de l'utilisateur connecté // Affichage de la page en fonction des paramètres envoyés if (page.compareTo("login") == 0) { dispatch(request, response, login); } else if (page.compareTo("accueil_gauche") == 0) { dispatch(request, response, accueil_gauche); } else if (page.compareTo("apropos") == 0) { dispatch(request, response, apropos); } else if (page.compareTo("fichier_primes") == 0) { Upload upload = new Upload(getServletContext().getRealPath(PATH_STATIC)); try { File fichier = new File(getServletContext().getRealPath(PATH_IMPORTS + XLS_PRIMES)); if (fichier.exists()) { fichier.delete(); } HashMap map = new HashMap(); Destination destinationFichier = new Destination(XLS_PRIMES, REP_IMPORTS); map.put("fichier", destinationFichier); upload.setDestinations(map); upload.telecharger(request); } catch (Exception e) { logger.info("Erreur de chargement de fichier : " + e.getMessage()); } dispatch(request, response, import_primes); } else if (page.compareTo("fichier_baremes") == 0) { Upload upload = new Upload(getServletContext().getRealPath(PATH_STATIC)); try { File fichier = new File(getServletContext().getRealPath(PATH_IMPORTS + XLS_BAREMES)); if (fichier.exists()) { fichier.delete(); } HashMap map = new HashMap(); Destination destinationFichier = new Destination(XLS_BAREMES, REP_IMPORTS); map.put("fichier", destinationFichier); upload.setDestinations(map); upload.telecharger(request); } catch (Exception e) { logger.info("Erreur de chargement de fichier : " + e.getMessage()); } dispatch(request, response, import_baremes); } } catch (Exception exc) { // Affichage de l'erreur retournée par l'exception logger.error("Erreur dans la méthode doGet() : " + exc.getMessage()); } } /** * Méthode doPost de la servlet qui renvoi sur le traitement de la méthode doGet * * @param request requête envoyée par le client à la servlet * @param response réponse retournée par la servlet au client * @throws ServletException * @throws IOException */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } /** * Méthode dispatch * * @param request requête envoyée par le client à la servlet * @param response réponse retournée par la servlet au client * @param nextPage la page d'afichage * @throws ServletException * @throws IOException */ public void dispatch(HttpServletRequest request, HttpServletResponse response, String nextPage) throws ServletException, IOException { RequestDispatcher dispatch = request.getRequestDispatcher(nextPage); dispatch.forward(request, response); } /** * Destruction de la servlet. */ public void destroy() { super.destroy(); } }
Merci de votre aide,
NarbO
Partager