Struts: servlet action pas dispo

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

1 réponse

Pas d'nom
 
Avant de polluer un peu plus le Web avec des questions nulles, ou des rèponses aussi nulles que celle ci, tape "Servlet action n'est pas disponible" sur Google, et fait ton choix
0
art
 
Merci Mr le .. !

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;
}
}

-------------------------
0
art
 
Je pense que la servlet est appelée ici :

dataSource = (DataSource)servlet.getServletContext().getAttribute("TabVehicule");

Que faut-il modifier ou ajouter ?
0