Hi,

I've got a bizarre problem regarding form validation. A simple form is 
validated, and when failing this validation I get a blank html page with 
the following source: <html><body></body></html>

The last message in the log is:

Validation failed, returning to '/upload.jsp'

I've read in another thread that somone else experienced the same thing. 
The solution in this case was to use a different commons-validation.jar.

I'm using exactly the same jars as the validation example application. 
Still with the same result.

Why am I not receiving the original form, like in the validation example?

I've included the following files for review:

- upload.jsp // The file containing the html.
- web.xml
- struts-config.xml
- validation.xml
- UploadBean.java

Any help would be greatly appreciated!

Kind regards

Rune Bjørnstad
/*
 * UploadBean.java
 *
 * Created on 1. juni 2003, 22:24
 */

package brylex.baltazar.bean;

import org.apache.struts.validator.ValidatorForm;
import org.apache.struts.upload.FormFile;
import org.apache.commons.fileupload.FileItem;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author  rune
 */
public class UploadBean extends ValidatorForm implements java.io.Serializable {
    
    private FormFile file = null;
    private ImageBean imageBean;
    private String title;
    
    public String getTitle() {
        return title;
    }
    
    public void setTitle( String title ) {
        this.title = title;
    }
    
    public FormFile getFile() {
        return file;
    }
    
    public void setFile( FormFile file ) {
        this.file = file;
    }
    
    public ImageBean getImageBean() {
        return imageBean;
    }
    
    public void setImageBean( ImageBean imageBean ) {
        this.imageBean = imageBean;
    }
    
    public boolean isInitialized() {
        return !(imageBean == null);
    }
    
    public void reset(ActionMapping mapping, HttpServletRequest request) {
        title = null;
        file = null;
    }
    
    public String toString() {
        return "UploadBean("+file+", "+imageBean+")";
    }
    
}
<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE form-validation PUBLIC "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.0//EN" "http://jakarta.apache.org/commons/dtds/validator_1_0.dtd";>

<form-validation>

   <global>

      

      

   </global>

   <formset>

      <!--

      <form name="uploadBean">

         <field property="title" depends="required,minlength">

         	     <arg0 key="uploadBean.title" />

         	     <arg1 name="minlength" key="${var:minlength}" resource="false" />

                     

                     <var>

                       <var-name>minlength</var-name>

                       <var-value>5</var-value>

                     </var>

         </field>

      </form>

      -->      

      <form name="uploadBean">

         <field property="title" depends="required">

         	     <arg0 key="uploadBean.title" />         	     

         </field>

      </form>

      

   </formset>

</form-validation>

<?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";>



<!--

     This is the Struts configuration file for the example application,

     using the proposed new syntax.



     NOTE:  You would only flesh out the details in the "form-bean"

     declarations if you had a generator tool that used them to create

     the corresponding Java classes for you.  Otherwise, you would

     need only the "form-bean" element itself, with the corresponding

     "name" and "type" attributes.

-->



<struts-config>



  <!-- ========== Form Bean Definitions =================================== -->

    <form-beans>



    <!-- Logon form bean -->

        <form-bean name="uploadBean" type="brylex.baltazar.bean.UploadBean"/>

                

        <form-bean name="databaseBean" type="brylex.baltazar.bean.DatabaseBean"/>

        <form-bean name="albumBean" type="brylex.baltazar.bean.impl.AlbumBeanImpl"/>

        <form-bean name="imageBean" type="brylex.baltazar.bean.impl.ImageBeanImpl"/>

        

    <form-bean name="userBean" type="brylex.baltazar.bean.impl.UserBeanImpl"/></form-beans>





  <!-- ========== Global Forward Definitions ============================== -->

    <global-forwards/>

   

  <!-- ========== Action Mapping Definitions ============================== -->

    <action-mappings>



    <!-- Edit user registration -->

        <action path="/upload" 

                type="brylex.baltazar.web.struts.action.UploadAction" 

                name="uploadBean"

                scope="request" 

                validate="true"                

                input="/upload.jsp">



            <forward name="success" path="/jsp/saveImage.jsp" />

            <forward name="failure" path="/jsp/upload.jsp" />

            

        </action>



        <action path="/loadAlbum" parameter="albumId" type="brylex.baltazar.web.struts.action.LoadAlbumAction" name="albumBean" scope="session">

            <forward name="success" path="/jsp/album.jsp" redirect="true"/>

            <forward name="failure" path="/jsp/failure.html" redirect="false"/>

        </action>

        <action path="/createAlbum" type="brylex.baltazar.web.struts.action.CreateAlbumAction" name="albumBean" input="/jsp/struts/createAlbum.jsp" validate="false">

            <forward name="success" path="/jsp/album.jsp" redirect="true"/>

            <forward name="failure" path="/jsp/sfailure.html" redirect="false"/>

            <forward name="load_form" path="/jsp/createAlbum.jsp" redirect="false"/>

        </action>

         <action path="/saveImage" type="brylex.baltazar.web.struts.action.SaveImageAction" validate="true" name="imageBean" scope="session" input="/jsp/struts/saveImage.jsp">

        <forward name="success" path="/jsp/album.jsp" redirect="true"/>

        <forward name="failure" path="/jsp/sfailure.html" redirect="false"/>

        <forward name="load_form" path="/jsp/saveImage.jsp" redirect="false"/>

    </action>

    <action path="/createUser" type="brylex.baltazar.web.struts.action.CreateUserAction" name="userBean" validate="false" scope="session" input="/jsp/harvester.jsp"><forward name="success" path="/jsp/security.jsp" redirect="false"/><forward name="harvest" path="/jsp/harvester.jsp" redirect="false"/><forward name="original" path="/jsp/test" redirect="true"/></action><action path="/session" parameter="action" unknown="true" type="brylex.baltazar.web.struts.action.SessionAction"><forward name="success" path="/jsp/invalidated.jsp" redirect="false"/></action></action-mappings>

   



  <!-- ========== Controller Configuration ================================ -->



    <controller maxFileSize="2M" tempDir="/tmp">

    <!-- The "input" parameter on "action" elements is the name of a

         local or global "forward" rather than a subapp-relative path -->

        <set-property property="inputForward" value="true"/>

        <set-property property="maxFileSize" value="2M"/>

        <set-property property="tempDir" value="/tmp"/>



    </controller>

    <message-resources parameter="MessageBundle"/>

    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">

      <set-property property="pathnames" value="/WEB-INF/xml/validator-rules.xml, /WEB-INF/xml/validation.xml"/>

      <set-property property="stopOnFirstError" value="true"/>

    </plug-in>

  



  <!-- <plug-in className="org.apache.struts.webapp.example.FacesPlugIn"/> -->





</struts-config>



<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app 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 web-app_2_4.xsd" version="2.4">



  <!-- Environment variables: -->

    <context-param>

        <param-name>imageRootPath</param-name>

        <param-value>/home/rune/devel/tmp/</param-value>

    </context-param>



    <context-param>

        <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>

        <param-value>MessageBundle</param-value>

    </context-param> 

  

  <!-- Initialization filter: -->

  <filter>

        <filter-name>InitFilter</filter-name>

        <filter-class>brylex.baltazar.web.filter.BaltazarInitFilter</filter-class>

    </filter>

    <filter-mapping>

        <filter-name>InitFilter</filter-name>

        <url-pattern>/*</url-pattern>

    </filter-mapping>

   

  <!-- 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/xml/struts-config.xml</param-value>

        </init-param>

        <init-param>

            <param-name>debug</param-name>

            <param-value>3</param-value>

        </init-param>

        <init-param>

            <param-name>detail</param-name>

            <param-value>3</param-value>

        </init-param>

        <load-on-startup>2</load-on-startup>

    </servlet>

  <!--

  <servlet>

    <servlet-name>ImageServlet</servlet-name>

    <servlet-class>brylex.baltazar.web.ImageServlet</servlet-class>

  </servlet>

  

  <servlet>

    <servlet-name>ThumbnailServlet</servlet-name>

    <servlet-class>brylex.baltazar.web.ThumbnailServlet</servlet-class>

  </servlet>-->



    <servlet>

        <servlet-name>UploadServlet</servlet-name>

        <servlet-class>brylex.baltazar.web.UploadServlet</servlet-class>

    </servlet>

    

  <!-- Action Servlet Mapping -->

    <servlet-mapping>

        <servlet-name>action</servlet-name>

        <url-pattern>*.do</url-pattern>

    </servlet-mapping>

  <!--

  <servlet-mapping>

    <servlet-name>ImageServlet</servlet-name>

    <url-pattern>/ImageServlet</url-pattern>

  </servlet-mapping>

  <servlet-mapping>

    <servlet-name>ThumbnailServlet</servlet-name>

    <url-pattern>/ThumbnailServlet</url-pattern>

  </servlet-mapping>-->

    <servlet-mapping>

        <servlet-name>UploadServlet</servlet-name>

        <url-pattern>/UploadServlet</url-pattern>

    </servlet-mapping>

  

  

  <!-- The Welcome File List: -->

    <welcome-file-list>

        <welcome-file>index.html</welcome-file>

    </welcome-file-list>

  

  <!-- Exception mappings: -->

  <!--  <error-page>

        <exception-type>java.lang.Throwable</exception-type>

        <location>/jsp/errorpage.jsp</location>

    </error-page>

  -->

  <!-- Tag libraries: -->

    

    <taglib>

        <taglib-uri>/WEB-INF/jstl-c.tld</taglib-uri>

        <taglib-location>/WEB-INF/tlds/c.tld</taglib-location>

    </taglib>

    <taglib>

        <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>

        <taglib-location>/WEB-INF/tlds/struts-bean.tld</taglib-location>

    </taglib>

    <taglib>

        <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>

        <taglib-location>/WEB-INF/tlds/struts-html.tld</taglib-location>

    </taglib>

    <taglib>

        <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>

        <taglib-location>/WEB-INF/tlds/struts-logic.tld</taglib-location>

    </taglib>

  

  <!-- SECURITY CONSTRAINT -->

    <security-constraint>



        <web-resource-collection>

            <web-resource-name>BaltazarCollection</web-resource-name>

            <url-pattern>/*</url-pattern>

            <http-method>POST</http-method>

            <http-method>GET</http-method>

        </web-resource-collection>

        <auth-constraint>

            <role-name>baltazar</role-name>

        </auth-constraint>



    </security-constraint>

  

  <!-- LOGIN AUTHENTICATION -->

    <login-config>

        <auth-method>BASIC</auth-method>

    </login-config>

  

  <!-- SECURITY ROLES -->

    <security-role>

        <role-name>baltazar</role-name>

    </security-role>



</web-app>

<[EMAIL PROTECTED] language="java"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"; prefix="fmt" %>
<%@ taglib uri="/WEB-INF/jstl-c.tld"        prefix="c" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<fmt:setLocale value="${userBean.locale}"/>
<fmt:setBundle basename="MessageBundle"/>

<html:html>
<head>

  <title>Image Publisher</title>
  
  <SCRIPT language="JavaScript" src="<c:url value="/script/calendar1.js"/>" ></SCRIPT>
  <html:base/>
</head>
<body>

 <TABLE>
    
    <TR>
      <TD>

<logic:messagesPresent>
   <bean:message key="errors.header"/>
   <ul>
   <html:messages id="error">
      <li><bean:write name="error"/></li>
   </html:messages>
   </ul><hr>
</logic:messagesPresent>


<html:form action="upload">
<TABLE>
  <TR>
    <TD>
      <fmt:message key="choose_image"/>:
    </TD>
  </TR>
  
  <TR>
    <TD>
      <fmt:message key="title"/>:
    </TD>
  </TR>
  <TR>
    <TD>
      <html:text property="title" />
    </TD>
  </TR>
  <TR>
    <TD><html:submit property="submit"/></TD>
  </TR>
</TABLE>
</html:form>

      </TD>
    </TR>
  </TABLE>

</body>

</html:html>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to