Bonsoir,
j'ai passé toute la journée à essayer de regler le problème en vain, pourtant c des exemples touts simple qui existent un peu partout

j'ai une pasge d'authentification par login et password que je teste en dur pour commencer c la page login.jsp
j'utilise deux classes LoginForm et LoginAction tel que décrits dans l'exemple
voici les differents sources:
fichier struts-config.xml:
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
<?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="loginForm" type="mesClasses.LoginForm">
            <form-property name="pass" type="java.lang.String"  initial="ok" />
            <form-property name="nom" type="java.lang.String"  initial="ok" />
        </form-bean>
   </form-beans>
<action-mappings>
<!--ACCUEIL-->
<action
path="/index"
parameter="/index.jsp"
type="org.apache.struts.actions.ForwardAction"
/>
<!--AUTHENTIFICATION-->
<action
            path="/login"
			parameter="/vue/login.jsp"
            input="/vue/erreurs.jsp"
            name="loginForm"
			scope="request"
			validate="true"
            type="mesClasses.LoginAction">
            <forward name="log_failed" path="/vue/erreurs.jsp" />
            <forward name="log_ok" path="/vue/accueil.jsp" />
        </action>
 
</action-mappings>
<message-resources parameter="resources.TestResources"/>
</struts-config>
fichier LoginForm:
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
package mesClasses;
 
import javax.servlet.http.HttpServletRequest;
 
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
 
 
 
public class LoginForm extends ActionForm
{
	// --------------------------------------------------------- Instance Variables
	/** pass property */
	private String pass=null;
	/** nom property */
	private String nom=null;
 
	// --------------------------------------------------------- Methods
 
	public void reset(ActionMapping mapping, HttpServletRequest request)
	{
		nom = null;
		pass = null;
	}
 
 
	public ActionErrors validate(
		ActionMapping mapping,
		HttpServletRequest request)
	{
		ActionErrors ae = new ActionErrors();
 
		if (nom.length() == 0)
		{
			ae.add("nom", new ActionError("error.login"));
 
		}
		if (pass.length() == 0)
		{
			ae.add("pass", new ActionError("error.password"));
 
		}
 
		return ae;
 
 
	public String getPass()
	{
		return pass;
	}
 
	public void setPass(String pass)
	{
		this.pass = pass;
	}
 
	public String getNom()
	{
		return nom;
	}
 
	public void setNom(String nom)
	{
		this.nom = nom;
	}
}
fichier LoginAction

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
package mesClasses;
import java.io.PrintWriter;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
 
import mesClasses.LoginForm; //importation de la classe associé au formulaire 
							//(méthodes de récupération de la saisie)
 
public class LoginAction extends Action
{
	public ActionForward execute(
		ActionMapping mapping,
		ActionForm form,
		HttpServletRequest request,
		HttpServletResponse response)
		throws Exception
	{
		LoginForm loginForm = (LoginForm)form;
 
		String username = loginForm.getNom();//méthode definit dans LoginForm
		String password =loginForm.getPass();//méthode definit dans LoginForm
 
		if (username.equals("admin") && password.equals("admin"))
		{
				return mapping.findForward("log_ok");
		}	else
			{
				//loginForm.setPass(null);
				//loginForm.reset(mapping, request);
				return mapping.findForward("log_failed");
			}
 
	}
}
fichier TestResources.properties
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
 
 
index.title = Bienvenue sur la Page Accueil
login.username = Votre Nom Utilisateur
login.password = Votre Mot de Passe
error.login = Login Incorrect
error.password = Password Incorrect
et voici l'erreur qui s'affiche:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
java.lang.NullPointerException
	mesClasses.LoginForm.validate(LoginForm.java:35)
	org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:942)
	org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:255)
	org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
	org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
c quoi mon erreur???
Merci d'avance[/code]