Bonsoir,
J'ai un problème qui me saoule, le voici:
J'ai conçu une appli avec:
Une servlet Genere qui génére les pages JSP (avec du XSL)
Une servlet Controle qui controle les requetes des formulaires et opère les actions.
Par exemple:
Dans Genere:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { log.debug("Genere.execute"); String parameter = mapping.getParameter(); log.debug("parameter="+parameter); if (parameter.equals("AUTHENTIFICATION")) { return genereAuthentification(mapping, form, request, response); } else .....
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 private ActionForward genereAuthentification(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { log.debug("Action = genere Authentification."); request.getSession(false).setMaxInactiveInterval(1); log.debug("TimeOut="+request.getSession(false).getMaxInactiveInterval() + "sec."); ... return (mapping.findForward("success")); }
Dans Controle:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { log.debug("Controle.execute"); String input = mapping.getInput(); String name = mapping.getName(); log.debug("input="+input); if (input.equals("adminAuthentification")) { return authentification(mapping, form, request, response); } else if ...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 private ActionForward authentification(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { log.debug("Action = authentification."); String forward = _ADMINHOME; ... return (mapping.findForward(forward)); }
Struts-config:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 ... <form-beans> <form-bean name="AuthentificationForm" type="org.apache.struts.action.DynaActionForm"> <form-property name="login" type="java.lang.String" /> <form-property name="password" type="java.lang.String" /> <form-property name="error" type="java.lang.String" /> </form-bean>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 <global-forwards> <forward name="Authentification" path="/Authentification.do" redirect="false" /> <forward name="TimeOut" path="/Authentification.do" redirect="false" />...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 <action-mappings> <action path="/Authentification" type="fr.app.struts.action.GenereAction" parameter="AUTHENTIFICATION"> <forward name="success" path="/pages/Authentification.jsp" redirect="false" /> </action> ... <action input="Authentification" name="AuthentificationForm" path="/AuthentificationAction" scope="request" type="fr.app.struts.action.ControleAction" validate="true" />
et puis le JSP:
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 <html:form action="/AuthentificationAction" method="POST"> <table class="xx"> <tr> <td class="xx"> <div class="xx">Login</div> </td> <td class="xx"> <input id="login" name="login" type="text"/> </td> </tr> <tr> <td class="xx"> <div class="xx">Mot de passe</div> </td> <td class="xx"> <input id="password" name="password" type="password"/> </td> </tr> </table> <div class="xx"> <input type="reset" id=reset" value="Reinitialiser"/> <input type="button" id="valider" value="Valider" onClick="validerFormulaire();"/> <br/> <html:errors property="error"/> </div> </html:form> <script language="Javascript"> function validerFormulaire() { if ((document.getElementById('login').value == "") || (document.getElementById('password').value == "")) { alert("Veuillez saisir vos login et mot de passe."); } else { document.AuthentificationForm.submit(); } } </script>
Enfin ma question:
QUESTION 1
Quand je lance l'appli, j'execute sur l'URL htp://localhost:9080/app/Authentification.do. Apres validation du formulaire, j'obtiens dans l'URL htp://localhost:9080/app/AuthentificationAction.html
Or je souhaiterai obtenir htp://localhost:9080/app/Home.do
J'ai essayé de mettre les forwards à "true", mais je perds les variables mises dans la request.
QUESTION 2
J'ai mis le timeout à 1 et pourtant la session reste vivante??
J'ai pourtant supprimé les cookies, mais sans résultats...
Comment faire???
Merci d'avance,
Billy
Partager