GeeCON Prague 2014*
The moose likes Struts and the fly likes Client side form validation not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Client side form validation not working" Watch "Client side form validation not working" New topic
Author

Client side form validation not working

kavitha kandula
Greenhorn

Joined: Aug 11, 2007
Posts: 6
Hi,

I devloped a small struts project using Netbeans IDE for client side validation.

I got the below error.i have commons-validator.jar in the classpath.



org.apache.jasper.JasperException: ValidatorResources not found in application scope under key "org.apache.commons.validator.VALIDATOR_RESOURCES"
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)


root cause

javax.servlet.ServletException: ValidatorResources not found in application scope under key "org.apache.commons.validator.VALIDATOR_RESOURCES"
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.Address_jsp._jspService(Address_jsp.java:99)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)


root cause

javax.servlet.jsp.JspException: ValidatorResources not found in application scope under key "org.apache.commons.validator.VALIDATOR_RESOURCES"
org.apache.struts.taglib.html.JavascriptValidatorTag.renderJavascript(JavascriptValidatorTag.java:373)
org.apache.struts.taglib.html.JavascriptValidatorTag.doStartTag(JavascriptValidatorTag.java:349)
org.apache.jsp.Address_jsp._jspx_meth_html_javascript_0(Address_jsp.java:281)
org.apache.jsp.Address_jsp._jspx_meth_html_form_0(Address_jsp.java:140)
org.apache.jsp.Address_jsp._jspService(Address_jsp.java:89)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)


Here with specifying the struts-config.xml
<?xml version="1.0" encoding="UTF-8" ?>


<!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="AddressFormBean" type="com.myapp.struts.AddressFormBean"/>


</form-beans>

<global-exceptions>

</global-exceptions>

<global-forwards>
<forward name="Client" path="/Address.jsp"/>

<forward name="welcome" path="/Welcome.do"/>
</global-forwards>

<action-mappings>
<action input="/Address.jsp" name="AddressFormBean" path="/AddressJavascriptValidation" scope="session"
type="com.myapp.struts.AddressAction">
<forward name="SUCCESS" path="/Results.jsp"/>

</action>
<action path="/Welcome" forward="/welcomeStruts.jsp"/>
</action-mappings>




<controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>

<message-resources parameter="com/myapp/struts/ApplicationResource"/>

<!-- ========================= Tiles plugin ===============================-->
<!--
This plugin initialize Tiles definition factory. This later can takes some
parameters explained here after. The plugin first read parameters from
web.xml, thenoverload them with parameters defined here. All parameters
are optional.
The plugin should be declared in each struts-config file.
- definitions-config: (optional)
Specify configuration file names. There can be several comma
separated file names (default: ?? )
- moduleAware: (optional - struts1.1)
Specify if the Tiles definition factory is module aware. If true
(default), there will be one factory for each Struts module.
If false, there will be one common factory for all module. In this
later case, it is still needed to declare one plugin per module.
The factory will be initialized with parameters found in the first
initialized plugin (generally the one associated with the default
module).
true : One factory per module. (default)
false : one single shared factory for all modules
- definitions-parser-validate: (optional)
Specify if xml parser should validate the Tiles configuration file.
true : validate. DTD should be specified in file header (default)
false : no validation

Paths found in Tiles definitions are relative to the main context.
-->
<plug-in className="org.apache.struts.tiles.TilesPlugin" >
<set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />
<set-property property="moduleAware" value="true" />
</plug-in>

<!-- ========================= Validator plugin ================================= -->
<!-- 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>


web.xml file
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.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>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</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>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>
index.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>


Thanks in Advance
[ September 17, 2007: Message edited by: kavitha kandula ]
Zip Ped
Ranch Hand

Joined: Jul 26, 2005
Posts: 336
Could you check if your validator-rules.xml and validations.xml are spelt correctly and you have the files with the same name.
kavitha kandula
Greenhorn

Joined: Aug 11, 2007
Posts: 6
Hi,

Yes i think the names should be validation.xml and validator-rules.xml.
They are spelled correctly but still getting the error
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Another thing to check would be to make sure that all jar files in your WEB-INF/lib directory come from the download of the Struts version you're using. In particular, make sure that the commons-validator jar file is the right one for your Struts version.
[ September 17, 2007: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
kavitha kandula
Greenhorn

Joined: Aug 11, 2007
Posts: 6
The jar files corectly belongs to struts version which iam using but not able to trace the problem
Arun R. S. Chandran
Ranch Hand

Joined: Oct 08, 2008
Posts: 81

Hi Kavitha,

I'm also facing the same problem.
If you got any solution for this problem, please help me to correct the same.

Thanks in advance

-Arun

Arun R. S. Chandran
Ranch Hand

Joined: Oct 08, 2008
Posts: 81

Hi Kavitha,

I'm also facing the same problem.
If you got any solution for this problem, please help me to correct the same.

Thanks in advance

-Arun

 
GeeCON Prague 2014
 
subject: Client side form validation not working