You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Carl Bacher <cb...@wellinx.com> on 2002/09/05 22:42:13 UTC

ActionForm.validate() method causing JasperException

I'm new to struts and trying to validate a form using the ActionForm's 
validate method. I'm using struts 1.0.2, tomcat 4.1.7 on NT.

When the validate attribute is set to false, everything seems to be 
working fine.
When I set the validate attribute to true, reload the webapp, and access 
the page, I get the following exception:

org.apache.jasper.JasperException
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:232)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:289)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:683)
	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:431)
	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:355)
	at org.apache.struts.action.ActionServlet.processValidate(ActionServlet.java:2149)
	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1565)
	at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:492)

...

root cause

java.lang.NullPointerException
	at java.util.Hashtable.put(Hashtable.java:375)
	at org.apache.jasper.runtime.PageContextImpl.setAttribute(PageContextImpl.java:236)
	at org.apache.struts.taglib.bean.DefineTag.doStartTag(DefineTag.java:210)
	at org.apache.jsp.user$jsp._jspService(Unknown Source)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:109)

...

I overrode the validate method in my ActionForm similar to the 
struts-example:

public ActionErrors validate(ActionMapping mapping,HttpServletRequest 
request)
{
    ActionErrors errors = new ActionErrors();
    if ((name == null) || (name.length() < 1))
        errors.add("name", new ActionError("error.name.required"));
    return errors;
}

The ApplicationResource.properties file is set up in web.xml with a 
error.name.required entry.

The action entry in the struts-config.xml looks like this:

<action path="/editUser"
        type="com.usrx.maintenance.EditUserAction"
        name="userForm"
        scope="request"
        input="/user.jsp"
        validate="true">
  <forward name="save"    path="/save.do"/>
  <forward name="cancel"  path="/main.jsp"/>
</action>

Am I missing something in the configuration?
Any ideas?

Thanks, Carl