bonjour tous le monde
je suis encore debutant dans le monde J2EE et ces freamwork
je viens de suivre un tutoriel comment faire un formulaire de login avec struts
il me donne toujours la meme erreur et je pense que j'ai suivi le tutoriel a la lettre
voici l'erreur :
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 description Le serveur a rencontré une erreur interne () qui l'a empêché de satisfaire la requête. exception org.apache.jasper.JasperException: java.lang.NullPointerException: Module 'null' not found. org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:491) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) cause mère java.lang.NullPointerException: Module 'null' not found. org.apache.struts.taglib.TagUtils.getModuleConfig(TagUtils.java:755) org.apache.struts.taglib.TagUtils.getModuleConfig(TagUtils.java:735) org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:818) org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:488) org.apache.jsp.login_jsp._jspx_meth_html_005fform_005f0(login_jsp.java:138) org.apache.jsp.login_jsp._jspService(login_jsp.java:94) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) note La trace complète de la cause mère de cette erreur est disponible dans les fichiers journaux de Apache Tomcat/6.0.29.
voici mes codes:
web.xml
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
35
36
37
38
39
40
41
42
43
44
45 <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <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> <load-on-startup>2</load-on-startup> </servlet> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>login.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>
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 <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd"> <struts-config> <form-beans> <form-bean name="LoginForm" type="com.tst.LoginForm"/> </form-beans> <action-mappings> <action input="/login.jsp" name="LoginForm" path="/Login" scope="session" type="com.tst.LoginAction"> <forward name="success" path="/success.jsp" /> <forward name="failure" path="/failure.jsp" /> </action> <action path="/Welcome" forward="/welcomeStruts.jsp"/> </action-mappings> </struts-config>
login.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 <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <div style="color:red"> <html:errors /> </div> <html:form action="/Login" > User Name : <html:text name="LoginForm" property="userName" /> <br> Password : <html:password name="LoginForm" property="password" /> <br> <html:submit value="Login" /> </html:form> </body> </html>
sucess.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 <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <h1>Login Success. Welcome <bean:write name="LoginForm" property="userName"></bean:write></h1> </body> </html>
failure.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 <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <div style="color:red"> <h1>Invalid user name <bean:write name="LoginForm" property="userName"></bean:write></h1> </div> </body> </html>
LoginAction.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 package com.tst; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionForward; public class LoginAction extends org.apache.struts.action.Action { private final static String SUCCESS = "success"; private final static String FAILURE = "failure"; public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { LoginForm loginForm = (LoginForm) form; if ((loginForm.getUserName().equals("admin"))&&(loginForm.getPassword().equals("admin"))) { return mapping.findForward(SUCCESS); } else { return mapping.findForward(FAILURE); } } }
LoginForm.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 package com.tst; import javax.servlet.http.HttpServletRequest; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionMessage; public class LoginForm extends org.apache.struts.action.ActionForm { private String userName; private String password; /** * */ public LoginForm() { super(); // TODO Auto-generated constructor stub } public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if (userName == null || userName.length() < 1) { errors.add("userName", new ActionMessage("error.userName.required")); // TODO: add 'error.name.required' key to your resources } if (password == null || password.length() < 1) { errors.add("password", new ActionMessage("error.password.required")); // TODO: add 'error.name.required' key to your resources } return errors; } /** * @return the userName */ public String getUserName() { return userName; } /** * @param userName the userName to set */ public void setUserName(String userName) { this.userName = userName; } /** * @return the password */ public String getPassword() { return password; } /** * @param password the password to set */ public void setPassword(String password) { this.password = password; } }
Merci d'avance de votre aide
Partager