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:
Citation:
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:
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:
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:
Citation:
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?
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:
Citation:
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:
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> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<div align="center">
<table width="631" height="112" border="0" align="center">
<tr>
<td colspan="5" id="dateformat" height="20">
<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éinitialiser" >
</div></td>
</tr>
</table>
</div></td>
</tr>
</table>
<div align="center"></div></td>
</tr>
</table>
</div>
</form>
</body>
</html> |
web.xml
Code:
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:
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:
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:
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:
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