Struts: servlet action pas dispo
art
-
art -
art -
Bonjour,
J'utilise tomcat 5.5.17, j'ai fait une petite appli struts, mais j'ai le message d'erreur 404 :
- Servlet action n'est pas disponible.
- description : La ressource demandée (Servlet action n'est pas disponible.) n'est pas disponible.
bien que j'ai lancé tomcat, après avoir suivi les étapes de ce tutorial :
http://www.netbeans.org/kb/50/tutorial-webapps-struts.html
Je compte sur votre aide
D'avance merci
J'utilise tomcat 5.5.17, j'ai fait une petite appli struts, mais j'ai le message d'erreur 404 :
- Servlet action n'est pas disponible.
- description : La ressource demandée (Servlet action n'est pas disponible.) n'est pas disponible.
bien que j'ai lancé tomcat, après avoir suivi les étapes de ce tutorial :
http://www.netbeans.org/kb/50/tutorial-webapps-struts.html
Je compte sur votre aide
D'avance merci
chercher sur google est la première chose que j'ai faite voici l'xml et la class :
Dans l'xml, j'ai ajouté (comme indiqué dans le tutorial) ceci :
--------------------
<data-sources>
<data-source type="org.apache.commons.dbcp.BasicDataSource" key="TabVehicule">
<set-property property="driverClassName" value="org.apache.derby.jdbc.ClientDriver" />
<set-property property="url" value="jdbc:derby://localhost:1527/Application" />
<set-property property="username" value="nfe114" />
<set-property property="password" value="nfe114" />
<set-property property="validationQuery" value="SELECT*FROM VEHICULE" />
</data-source>
</data-sources>
---------------
la classe :
-------------------------
/*
* RechercheVehiculeParMarqueAction.java
*
* Created on 13 mai 2007, 14:25
*/
package com.myapp.struts;
import javax.servlet.http.*;
import org.apache.struts.action.*;
import java.sql.*;
import java.util.ArrayList;
import javax.sql.*;
/**
*
* @author helali
* @version
*/
public class RechercheVehiculeParMarqueAction extends Action {
private DataSource dataSource;
public ArrayList vehiculeList = new ArrayList();
private final static String SUCCESS = "success";
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception
{
HttpSession session = request.getSession();
/** Here the method that connects to the datasource is called: */
vehiculeList = getVehicules() ;
/** Here we put the vehiculeList in scope, so that we can use it in the JSP page: */
if(vehiculeList != null)
{
session.setAttribute("allMyCars", vehiculeList);
}
return (mapping.findForward(SUCCESS));
}
private ArrayList getVehicules()
{
Connection conn = null;
Statement stmt = null;
PreparedStatement prpStmt = null;
ResultSet rs = null;
StringBuffer resultString ;
try
{
/** Here 'empTable' maps to the datasource key defined in struts-config.xml: */
dataSource = (DataSource)servlet.getServletContext().getAttribute("TabVehicule");
conn = dataSource.getConnection();
String sqlQuery = "SELECT * FROM VEHICULE";
prpStmt = conn.prepareStatement(sqlQuery);
rs = prpStmt.executeQuery();
/** Here we put field 4 (the name) and field 7 (the city) in the vehiculeList: */
while (rs.next())
{
vehiculeList.add(new row(rs.getString(2), rs.getString(3)));
}
rs.close();
} catch ( SQLException e )
{
System.err.println("SQL Exception occured while accessing the table" );
e.printStackTrace();
return null;
}
catch ( Exception e )
{
e.printStackTrace();
return null;
}
return vehiculeList;
}
}
-------------------------
dataSource = (DataSource)servlet.getServletContext().getAttribute("TabVehicule");
Que faut-il modifier ou ajouter ?