IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Struts 1 Java Discussion :

prob fichier struts-config.xml


Sujet :

Struts 1 Java

  1. #1
    Membre à l'essai
    Inscrit en
    Août 2007
    Messages
    18
    Détails du profil
    Informations forums :
    Inscription : Août 2007
    Messages : 18
    Points : 14
    Points
    14
    Par défaut prob fichier struts-config.xml
    Bonjour,
    je developpe une application avec struts et qd je lance mon application en tapant l'URL normal , j'obtient ma page jsp.mais qu'on jutilise le .do , là ca bloque , jobtiens le message d'erreur suivant:
    message Servlet action n'est pas disponible.
    description La ressource demandée (Servlet action n'est pas disponible.) n'est pas disponible.
    voila mon fichier 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
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <servlet>
    <servlet-name>action</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>
    </servlet>
    <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
    <welcome-file>vues/auth.jsp</welcome-file> 
    </welcome-file-list>
    <taglib>
    <taglib-uri>/tags/struts-bean</taglib-uri>
    <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
    </taglib>
     
    <taglib>
    <taglib-uri>/tags/struts-html</taglib-uri>
    <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
    </taglib>
     
    <taglib>
    <taglib-uri>/tags/struts-logic</taglib-uri>
    <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
    </taglib>
     
    <taglib>
    <taglib-uri>/tags/struts-nested</taglib-uri>
    <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
    </taglib>
     
    <taglib>
    <taglib-uri>/tags/struts-tiles</taglib-uri>
    <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
    </taglib>
    </web-app>
    fichier 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
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE struts-config PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
    "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
    <struts-config>
    <form-beans>
    <form-bean
    name="frmauth"
    type="authBean"
    />
    </form-beans>
    <action-mappings>
    <action
    path="/main"
    name="frmauth"
    scope="session"
    validate="true"
    input="/accueil.do"
     
    type="authAction"
    <forward name="administrateur" path="/administrateur.do" />
    <forward name="user" path="/user.do" /> 
    <forward name="accueil" path="/accueil.do" /> 
    />
    <action path="/Welcome" forward="/vues/auth.jsp" /> 
    <action
    path="/accueil"
    parameter="/vues/auth.jsp"
    type="org.apache.struts.actions.ForwardAction"
    />
    <action
    path="/user"
    parameter="/vues/user.jsp"
    type="org.apache.struts.actions.ForwardAction"
    />
    <action
    path="/administrateur"
    parameter="/vues/administrateur.jsp"
    type="org.apache.struts.actions.ForwardAction"
    />
    </action-mappings>
    <controller processorClass="org.apache.struts.tiles.TilesRequestProcessor" /> 
     
    <message-resources parameter="ressources.authressources"/>
     
    <plug-in className="org.apache.struts.tiles.TilesPlugin" >
    <set-property property="definitions-config"
    value="/WEB-INF/tiles-defs.xml" />
     
    <!-- Set Module-awareness to true -->
    <set-property property="moduleAware" value="true" />
    </plug-in>
    <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>
    et quand j'essaie d'ouvrir la page struts-config.xml avec IE , j'ai l'erreur suivante:
    The XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.


    --------------------------------------------------------------------------------

    A name was started with an invalid character. Error processing resource 'file:///C:/Program Files/Apache Software Foundatio...

    <forward name="administrateur" path="/administrateur.do" />
    ^
    Je ne sais pas ou est l'erreur, quelqu'un peut m'aider?

  2. #2
    Membre à l'essai
    Inscrit en
    Août 2007
    Messages
    18
    Détails du profil
    Informations forums :
    Inscription : Août 2007
    Messages : 18
    Points : 14
    Points
    14
    Par défaut probleme réglé
    cété juste une erreur dans le fichier struts-config.xml a laquelle j'avais pas fais attention
    mtn , qd je lance mon application avec un .do jobtiens l'erreur suivante;
    message Servlet action n'est pas disponible.

    description La ressource demandée (Servlet action n'est pas disponible.) n'est pas disponible.
    merci d'avance

  3. #3
    Membre actif
    Homme Profil pro
    Développeur Java
    Inscrit en
    Août 2007
    Messages
    197
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Août 2007
    Messages : 197
    Points : 246
    Points
    246
    Par défaut
    si tu pouvais nous en dire un peu plus comme par exmple quel action (.do) tu appel? donne nous ton exception complete, quel est ton serveur d'application?, ......

  4. #4
    Membre à l'essai
    Inscrit en
    Août 2007
    Messages
    18
    Détails du profil
    Informations forums :
    Inscription : Août 2007
    Messages : 18
    Points : 14
    Points
    14
    Par défaut
    Salut,
    j'utilise tomcat5.5 , une BD postgresql et eclipse comme IDE .
    En ce qui concerne l'action, c'est auth.do qui appele la page vues/auth.jsp contenant un formulaire pour authentification.
    Et pour l'exception, c'est tout ce que j'obtiens comme erreur:

    message Servlet action n'est pas disponible.

    description La ressource demandée (Servlet action n'est pas disponible.) n'est pas disponible.

  5. #5
    Membre du Club
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    55
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : Maroc

    Informations forums :
    Inscription : Avril 2007
    Messages : 55
    Points : 49
    Points
    49
    Par défaut
    eck tu ai sure d avoir ajouter le mapping du filtre vers le .do dans ton fichier web.xml??
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    <filter-mapping>
       <filter-name>ResponseOverrideFilter</filter-name>
       <url-pattern>*.do</url-pattern>
     </filter-mapping>
     <filter-mapping>
       <filter-name>ResponseOverrideFilter</filter-name>
       <url-pattern>*.jsp</url-pattern>
     </filter-mapping>

  6. #6
    Modérateur
    Avatar de OButterlin
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    7 313
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 7 313
    Points : 9 529
    Points
    9 529
    Billets dans le blog
    1
    Par défaut
    Tu tapes quelle url ?
    Peut-on voir le code de la page ?

    D'habitude, tu appelles une action comme ceci :
    - dans une page (pour un lien par exemple) :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    <%=request.getContextPath()%>/nomAction.do [?nomParam1=Valeur1&nomParam2=Valeur2...]
    - dans la barre du navigateur :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    http://localhost:8080/NomProjet/nomAction.do
    Il est a noter que dans le cas de struts et des balises <html:form> ou <layout:form> tu ne mets que le nom de l'action (avec ou sans .do), le tag fera le reste...

    A+
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  7. #7
    Membre à l'essai
    Inscrit en
    Août 2007
    Messages
    18
    Détails du profil
    Informations forums :
    Inscription : Août 2007
    Messages : 18
    Points : 14
    Points
    14
    Par défaut premiere application struts
    salut,
    j'ai ajouté les filtres et ca ne marche pas.Quand je tape l'URL http://localhost:8080/nom_application/accueil.do , j'ai toujours la méme erreur:
    message Servlet action n'est pas disponible.

    description La ressource demandée (Servlet action n'est pas disponible.) n'est pas disponible.
    j'essaie de faire un formulaire auth.jsp pour authentification(login , mot de passe)
    ceux ci doivent etre vérifiés dans une base de données (table compte qui contient un attribut catégorie), et puis selon la catégorie de la personne loguée(administrateur ou utilisateur) , il faut renvoyer la page administrateur.jsp ou user.jsp.

    voici le contenu de auth.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
    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
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Page d accueil</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <script language="JavaScript" type="text/javascript">
    var d=new Date();
    monthname= new Array("Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre");
    var TODAY = monthname[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear();
    </script>
    <style type="text/css">
    <!--
    .Style1 {
    	font-size: 28px;
    	color: #000000;
    	font-family: "Times New Roman", Times, serif;
    }
    #Layer1 {	position:absolute;
    	left:371px;
    	top:22px;
    	width:409px;
    	height:32px;
    	z-index:1;
    }
    #Layer2 {	position:absolute;
    	left:316px;
    	top:67px;
    	width:564px;
    	height:24px;
    	z-index:2;
    }
    #Layer3 {
    	position:absolute;
    	left:369px;
    	top:58px;
    	width:324px;
    	height:33px;
    	z-index:2;
    }
    .Style6 {font-size: 12px; color: #000000; font-family: "Times New Roman", Times, serif; }
    .Style8 {
    	color: #000000;
    	font-size: 12px;
    }
    .Style9 {
    	font-size: 14px;
    	font-weight: bold;
    }
    body {
    	background-image: url(images/page_id.jpg);
    	background-repeat:no-repeat;
    	background-position:center;
    	//margin-bottom: -40%;
    }
    .Style2 {
    	color: #71A40B;
    	font-weight: bold;
    }
    .Style3 {
    	color: #E84466;
    	font-weight: bold;
    }
    .Style4 {color: #FFFFFF}
    -->
    </style>
    </head>
     
    <body >
     
    <form name="frmauth" method="post" action="/main">
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
        <p>&nbsp;</p>
     
     
        <div align="center">
          <table width="631" height="112" border="0" align="center">
            <tr>
      	<td colspan="5" id="dateformat" height="20">&nbsp;&nbsp;
      	  <div align="center">
      	    <script language="JavaScript" type="text/javascript">
          document.write(TODAY);	</script>
          </div></td>
      </tr>
            <tr>
              <td> 
     
                <table width="347" border="0" align="center">
                  <tr>
                    <td width="150" height="36"><div align="center" class="Style2">
                        <p align="left"> Identifiant : </p>
                    </div></td>
                    <td width="209"><div align="center">
                        <p>
                          <input type="text" name="name">
                        </p>
                    </div></td>
                  </tr>
                  <tr>
                    <td height="62"><div align="center" class="Style3">
                        <div align="left">Mot de passe : </div>
                    </div></td>
                    <td><div align="center">
                        <input type="password"  name="password" >
                    </div></td>
                  </tr>
                  <tr>
                    <td height="60" colspan="3"><div align="center">
                        <table width="242" border="0">
                          <tr>
                            <td width="118"><div align="center">
                                <input name="Submit" type="submit" class="Style3" value="Envoyer">
                            </div></td>
                            <td width="114"><div align="center">
                                <input name="Submit2" type="reset" class="Style2" value="R&eacute;initialiser" >
                            </div></td>
                          </tr>
                        </table>
                    </div></td>
                  </tr>
                </table>
              <div align="center"></div></td>
            </tr>
              </table>
        </div>
      </form>
    </body>
    </html>
    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
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <servlet>
    <servlet-name>action</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>2</param-value>
            </init-param>
            <init-param>
                <param-name>detail</param-name>
                <param-value>2</param-value>
            </init-param>
            <load-on-startup>2</load-on-startup>
            </servlet>
    <servlet-mapping>
    <filter-mapping>
       <filter-name>ResponseOverrideFilter</filter-name>
       <url-pattern>*.do</url-pattern>
     </filter-mapping>
     <filter-mapping>
       <filter-name>ResponseOverrideFilter</filter-name>
       <url-pattern>*.jsp</url-pattern>
     </filter-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
    </servlet-mapping>
    <session-config>
            <session-timeout>
                30
            </session-timeout>
    </session-config>
    <welcome-file-list>
    <welcome-file>vues/auth.jsp</welcome-file> 
    </welcome-file-list>
     <jsp-config>
            <taglib>
                <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
                <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
            </taglib>
            <taglib>
                <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
                <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
            </taglib>
            <taglib>
                <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
                <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
            </taglib>
            <taglib>
                <taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri>
                <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
            </taglib>
            <taglib>
                <taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
                <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
            </taglib>
      </jsp-config>
    </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
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE struts-config PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
    "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
    <struts-config>
    <form-beans>
            <form-bean
               name="frmauth"
               type="authBean"
    />
     
        </form-beans>
    <global-exceptions>
    </global-exceptions>
    <action-mappings>
    <action path="/Welcome" forward="/vues/auth.jsp" /> 
    <action path="/accueil" parameter="/vues/auth.jsp" type="org.apache.struts.actions.ForwardAction"/>
    <action path="/user" parameter="/vues/user.jsp" type="org.apache.struts.actions.ForwardAction" />
    <action path="/admin" parameter="/vues/admin.jsp" type="org.apache.struts.actions.ForwardAction" />
    <action path="/main" name="frmauth" scope="session" validate="true" input="/accueil.do" type="authAction" >
    <forward name="reponse" path="/reponse.do"/>
    </action>
     
    </action-mappings>
    <controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>
    <plug-in className="org.apache.struts.tiles.TilesPlugin" >
            <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />      
            <set-property property="moduleAware" value="true" />
    </plug-in>
    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
            <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
    </plug-in>
    <message-resources parameter="ressources.authressources"/>   
     
    </struts-config>
    classe authBean.java
    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
    import org.apache.struts.action.ActionForm;
    public class authBean extends ActionForm {
     
    private String name = null;
    public String getName() {
    return name;
    }
    public void setName(String name) {
    this.name = name;
    }
     
    private String password = null;
    public String getPassword() {
    return password;
    }
    public void setPassword(String password) {
    this.password = password;
    }
    }
    classe authAction.java
    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
    import bd.*;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.IOException;
    import javax.servlet.ServletException;
     
    public class authAction extends Action {
     
    public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
     
    // on a un formulaire valide
    authBean formulaire=(authBean)form;
    request.setAttribute("name",formulaire.getName());
    request.setAttribute("password",formulaire.getPassword());
     
    connexion connexion=new connexion();
    Connection conn=connexion.get_connexion();
    if ((conn.s).equals("true"))
     {
       if(conn.getCategorie(formulaire.getName(), formulaire.getPassword()).equals("utilisateur"))
         {
            conn.s="false";
            return mapping.findForward("user");
         }
       if (conn.getCategorie(formulaire.getName(), formulaire.getPassword()).equals("administrateur"))
          {
            conn.s="false";
            return mapping.findForward("administrateur");
         }
     
     } 
     else 
        return mapping.findForward("accueil");
    }
    }

    classe connexion.java
    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
    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
    package bd;
     
    import java.sql.*;
     
    public class connexion {
     
       private String url="jdbc:postgresql://localhost:5432/smsc";
       private String user="postgres";
       private String password="root";
       private String driver="org.postgresql.Driver";
       private ResultSetMetaData rsm;
       private ResultSet rs;
       public static boolean s = false;
       public static boolean s2 = false;
     
     
       public connexion()
       { 
       }
       public Connection get_connexion()
       {
       Connection con = null;
       try
       {
          Class.forName(driver);
          System.out.println("*** Driver OK ***");
          con = DriverManager.getConnection(url, user,password);
          System.out.println("->Connexion établie");
       }
       catch(ClassNotFoundException classnotfoundexception)
       {
           System.out.println((new StringBuilder()).append("erreur lors du chargement du pilote:").append(classnotfoundexception).toString());
       }
       catch(SQLException sqlexception)
       {
           System.out.println((new StringBuilder()).append("la connection a \351chou\351 :").append(sqlexception.getMessage()).toString());
       }
       return con;
       } 
       public String getCategorie(String log, String pass)
       {
           String res = "";
           try
           {
               String req = (new StringBuilder()).append("SELECT categorie FROM compte where login=\"").append(log).append("\" and pass=\"").append(pass).append("\"").toString();
               Statement stmt = get_connexion().createStatement();
               ResultSet rs;
               for( rs = stmt.executeQuery(req); rs.next();)
                   res = rs.getString("categorie");
           }
           catch(Exception exception) { }
           return res;
       }
     
     
       public void getUsers()
       {
           try
           {
               String req = "SELECT * FROM compte";
               Statement stmt = get_connexion().createStatement();
               ResultSet resultset = stmt.executeQuery(req);
           }
           catch(Exception exception) { }
       }
     
       public void verifie(String log, String pass)
       {
           try
           {
               String req = "SELECT * FROM compte";
               Statement stmt = get_connexion().createStatement();
               ResultSet resultset = stmt.executeQuery(req);
     
               do
               {
                   if(!resultset.next())
                       break;
     
    			if(log.equals(resultset.getString("login")) && pass.equals(resultset.getString("pass")))
                       s = true;
               } while(true);
           }
           catch(Exception exception)
           {
               System.out.println((new StringBuilder()).append("erreur :").append(exception.getMessage()).toString());
           }
       }
     
       public void inserer(String name, String pname, String log, String pass, String categorie , String email)
       {
           try
           {
               System.out.println((new StringBuilder()).append("voici le nom   ").append(name).toString());
     
              String req="INSERT INTO compte (nom,prenom, login,mot_de_passe,categorie, email)  values ('"+name+"','"+pname+"','"+log+"','"+pass+"','"+categorie+"','"+email+"');";
               Statement statement = get_connexion().createStatement();
               if(!name.equals("") && !pname.equals("") && !log.equals("") && !pass.equals("") && !categorie.equals("") && !email.equals(""))
               {
                   statement.executeUpdate(req);
                   s2 = true;
               } 
               else
               {
                   System.out.println("name="+name);
               System.out.println("pname="+pname);
               System.out.println(log);
               System.out.println(pass);
               System.out.println(categorie);
               System.out.println(email);
     
     
                   System.out.println("erreurs champs");
               }
           }
           catch(Exception exception)
           {
               System.out.println((new StringBuilder()).append("erreur :").append(exception.getMessage()).toString());
           }
       }
     
     
     
       public void supprimer(String name, String pname)
       {
           try
           {
               String req = (new StringBuilder()).append("delete from compte where nom='").append(name).append("' and prenom='").append(pname).append("';").toString();
              System.out.println(req);
               Statement statement = get_connexion().createStatement();
               statement.executeUpdate(req);
               System.out.println("finio");
           }
           catch(Exception exception)
           {
               System.out.println((new StringBuilder()).append("erreur :").append(exception.getMessage()).toString());
           }
       }
    }
    Je suis bloqué ici, j'ai besoin de votre aide.
    Merci

  8. #8
    Membre à l'essai
    Inscrit en
    Août 2007
    Messages
    18
    Détails du profil
    Informations forums :
    Inscription : Août 2007
    Messages : 18
    Points : 14
    Points
    14
    Par défaut
    c pas le bon fichier struts-config.xml,
    voici le bon:
    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
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE struts-config PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
    "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
    <struts-config>
    <form-beans>
            <form-bean
               name="frmauth"
               type="authBean"
    />
     
        </form-beans>
    <global-exceptions>
    </global-exceptions>
    <action-mappings>
    <action path="/Welcome" forward="/vues/auth.jsp" /> 
    <action path="/accueil" parameter="/vues/auth.jsp" type="org.apache.struts.actions.ForwardAction"/>
    <action path="/user" parameter="/vues/user.jsp" type="org.apache.struts.actions.ForwardAction" />
    <action path="/administrateur" parameter="/vues/administrateur.jsp" type="org.apache.struts.actions.ForwardAction" />
    <action path="/main" name="frmauth" scope="session" validate="true" input="/accueil.do" type="authAction" >
    <forward name="administrateur" path="/administrateur.do" redirect="true"/>
    <forward name="user" path="/user.do" redirect="true"/>
    </action>
     
    </action-mappings>
    <controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>
    <plug-in className="org.apache.struts.tiles.TilesPlugin" >
            <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />      
            <set-property property="moduleAware" value="true" />
    </plug-in>
    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
            <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
    </plug-in>
    <message-resources parameter="ressources.authressources"/>   
     
    </struts-config>

  9. #9
    Membre actif
    Homme Profil pro
    Développeur Java
    Inscrit en
    Août 2007
    Messages
    197
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Août 2007
    Messages : 197
    Points : 246
    Points
    246
    Par défaut
    re,
    au vu du resultat ton probleme est qu'il ne trouve pas ta page jsp (ta servlet puisque ta jsp sera transformée en servlet.) , le probleme viens sûrement de ton lien relatif dans ton fichier struts-config:
    cf:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    <action path="/accueil" parameter="/vues/auth.jsp" type="org.apache.struts.actions.ForwardAction"/>
    le meilleur moyen de savoir c'est que tu regarde dans la bare de navigation le lien qui est mis:
    par exemple dans ton cas ça risque d'etre quelquechose qui ressemble à ça:
    http://localhost:8080/nom_application/vues/auth.jsp
    il ne te reste plus qu' à vérifier la cohérence de ce lien avec ton serveur d'application (regarde l'arborescence dans le repertoire web de ton serveur en nottant que le '/' représente un 'sous arbre' de ton arborescence en gros tu imagine que dans l'exemple précédent ta page jsp se trouve bien réelement dans le repertoire: */nom_application/vues/auth.jsp avec * qui est le repertoire WEB de ton serveur WEB.) .(tu peux aussi tester avec les liens absolus, ça t'évitera ce problème)
    ++

Discussions similaires

  1. Réponses: 4
    Dernier message: 12/11/2009, 17h57
  2. erreur dans le fichier struts-config.xml
    Par j_esti dans le forum Struts 1
    Réponses: 4
    Dernier message: 16/05/2008, 13h26
  3. [Struts-menu] déplacer le fichier menu-config.xml
    Par mkc44 dans le forum Struts 1
    Réponses: 2
    Dernier message: 25/05/2007, 14h21
  4. Je ne trouve pas le fichier Struts-Config.xml
    Par masse dans le forum Eclipse Java
    Réponses: 1
    Dernier message: 06/10/2006, 10h33
  5. [struts]: struts-config.xml
    Par sleepy2002 dans le forum Struts 1
    Réponses: 2
    Dernier message: 01/10/2004, 10h32

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo