hi, i am new to sruts ..
i am using eclipse ganymede 3.4.2 along with tomcat 6.0.24, and struts 1.3.1
on a validation form in login.jsp following exception are shown by the apache tomcat
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
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)
root cause
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:149)
org.apache.jsp.login_jsp._jspService(login_jsp.java:98)
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 The full stack trace of the root cause is available in the Apache Tomcat/6.0.24 logs.
Here are
my login.jsp page :
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html" %>
<%@taglib uri="/WEB-INF/tld/struts-logic.tld" prefix="logic" %>
<%@taglib uri="/WEB-INF/tld/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=ISO-8859-1">
<title>eTask</title>
</head>
<body bgcolor="blue">
<h1>Login Form</h1>
<hr>
<html:errors property="login" />
<html:form action="/login" method="post" focus="userName"><br />
Login: <html:text property="userName" name="LoginForm" maxlength="25"/><br />
Password: <html:password property="userName" name="LoginForm" />
<html:submit value="Login"/>
<html:reset/>
</html:form>
</body>
</html>
my struts-config.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd">
<struts-config>
<form-beans>
<form-bean name="LoginForm" type="e.task.LoginForm"/>
</form-beans>
<!-- =========================================== Global Forward Definitions -->
<global-forwards>
<forward
name="login"
path="/login.jsp"/>
</global-forwards>
<!-- =========================================== Action Mapping Definitions -->
<action-mappings>
<action path="/login" forward="/login.jsp" />
<action
path="/login" name="/LoginForm"
type="e.task.LoginAction" scope="request"
validate="true" input="/login.jsp" parameter=" /login.jsp">
<forward name="success" path="/index.jsp"/>
<forward name="failure" path="/login.jsp"/>
</action>
</action-mappings>
<!-- ======================================== Message Resources Definitions -->
<message-resources parameter="/MessageResources" null="false" />
<!-- =============================================== Plug Ins Configuration -->
<!-- =================================================== Validator plugin -->
<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>
my web.xml
<?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>
<display-name>Struts Blank Application</display-name>
<!-- Standard Action Servlet Configuration -->
<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>
<!-- Standard Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<!-- The Usual Welcome File List -->
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
</web-app>
my validation.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.3.0//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_3_0.dtd">
<form-validation>
<!--
This is a minimal Validator form file with a couple of examples.
-->
<global>
<!-- An example global constant
<constant>
<constant-name>postalCode</constant-name>
<constant-value>^\d{5}\d*$</constant-value>
</constant>
end example-->
</global>
<formset>
<!-- An example form -->
<form name="logonForm">
<field
property="username"
depends="required">
<arg key="logonForm.username"/>
</field>
<field
property="password"
depends="required,mask">
<arg key="logonForm.password"/>
<var>
<var-name>mask</var-name>
<var-value>^[0-9a-zA-Z]*$</var-value>
</var>
</field>
</form>
</formset>
<!-- An example formset for another locale -->
<formset language="fr">
<constant>
<constant-name>postalCode</constant-name>
<constant-value>^[0-9a-zA-Z]*$</constant-value>
</constant>
<!-- An example form -->
<form name="logonForm">
<field
property="username"
depends="required">
<arg key="logonForm.username"/>
</field>
<field
property="password"
depends="required,mask">
<arg key="logonForm.password"/>
<var>
<var-name>mask</var-name>
<var-value>^[0-9a-zA-Z]*$</var-value>
</var>
</field>
</form>
</formset>
</form-validation>
i have included these file in WEB-IN/lib
antlr.jar
cglib-nodep-2.1_3.jar
commons-beanutils.jar
commons-chain-1.2.jar
commons-collections-3.1.jar
commons-digester.jar
commons-fileupload.jar
commons-lang-2.1.jar
commons-logging.jar
commons-validator.jar
csv.jar
displaytag-1.1.jar
displaytag-export-poi-1.1.jar
displaytag-portlet-1.1.jar
dom4j-1.6.jar
ehcache-1.1.jar
hibernate3.jar
itext-1.3.jar
jakarta-oro.jar
jstl-1.1.2.jar
jta.jar
jtds-1.2.jar
log4j-1.2.12.jar
oro-2.0.8.jar
poi-2.5.1.jar
servlet.jar
spring.jar
spring.tld
spring-aop.jar
spring-beans.dtd
spring-beans.jar
spring-context.jar
spring-core.jar
spring-dao.jar
spring-hibernate.jar
spring-jdbc.jar
spring-mock.jar
spring-orm.jar
spring-remoting.jar
spring-support.jar
spring-web.jar
spring-webmvc.jar
standard-1.0.6.jar
struts.jar
struts-taglib-1.3.10.jar
struts-tiles-1.3.10.jar
i have included these tld files in
WEB-INF/tld folder in my project
struts-bean.tld
struts-html.tld
struts-logic.tld
my MessageResources.properties
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
#
http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# -- standard errors --
errors.header=<font color="red">
#errors.prefix=<LI>
#errors.suffix=</LI>
errors.footer=</font>
# -- validator --
errors.invalid={0} is invalid.
errors.maxlength={0} can not be greater than {1} characters.
errors.minlength={0} can not be less than {1} characters.
errors.range={0} is not in the range {1} through {2}.
#---------------------------------------------
errors.userName.required=UserName is required.
errors.password.required=Password is required.
errors.login.invalid=The system couldnot verify your username and password.
Is your CAPS Lock ON?
Please try again.
#---------login page text----------------------
login.title= Login Please.
login.message=Please Login!
login.username=username.
login.password=password.
login.button.signon=Log In.
#-------------------------------------------
label.username=Login.
label.password=Password.
label.welcome=Welcome.
#--------------------------------------------
index.title=eTask Project
index.message=welcome,[0].
errors.byte={0} must be an byte.
errors.date={0} is not a date.
errors.double={0} must be an double.
errors.float={0} must be an float.
errors.integer={0} must be an integer.
errors.long={0} must be an long.
errors.short={0} must be an short.
errors.creditcard={0} is not a valid credit card number.
errors.email={0} is an invalid e-mail address.
# -- other --
errors.cancel=Operation cancelled.
errors.detail={0}
errors.general=The process did not complete. Details should follow.
errors.token=Request could not be completed. Operation is not in sequence.
# -- welcome --
welcome.title=Struts Blank Application
welcome.heading=Welcome!
welcome.message=To get started on your own application, copy the struts-blank.war to a new WAR file using the name for your application. Place it in your container's "webapp" folder (or equivalent), and let your container auto-deploy the application. Edit the skeleton configuration files as needed, restart your container, and you are on your way! (You can find the MessageResources.properties file with this message in the /WEB-INF/src folder.)
my LoginAction.java
package e.task;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
public class LoginAction extends 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(loginForm.getPassword()))
{
return mapping.findForward(SUCCESS);
}
else
{
return mapping.findForward(FAILURE);
}
}
}
my LoginForm.java
package e.task;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
public class LoginForm extends ActionForm {
/**
*
*/
private static final long serialVersionUID = -3720711292263799990L;
private String userName;
private String password;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public void reset(ActionMapping mapping,HttpServletRequest request)
{
password=" ";
userName=" ";
}
public ActionErrors validate(ActionMapping mapping,HttpServletRequest request)
{
ActionErrors errors=new ActionErrors();
if(userName==null||userName.length()<1)
{
errors.add("userName",new ActionMessage("errors.userName.required"));
}
if (password==null||password.length()<1)
{
errors.add("password",new ActionMessage("errors.password.required"));
}
return errors;
}
}