title: java.lang.ClassCastException: org.apache.struts.validator.DynaValidatorForm cannot be cast
body: <p>I want to search the data from jsp form in database and display it in another jsp file... </p>
  
  <pre><code>javax.servlet.ServletException: java.lang.ClassCastException: org.apache.struts.validator.DynaValidatorForm cannot be cast to org.mat.search.SearchFB
  org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:286)
  org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
  org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
  </code></pre>
  
  <p><strong>SearchFB.java</strong></p>
  
  <pre><code>import org.apache.struts.validator.DynaValidatorForm;
  
  public class SearchFB extends DynaValidatorForm {
  
  private String userName;
  private String caste[];
  private String qualification[];
  private Integer age;
  public String getUserName() {
      return userName;
  }
  public void setUserName(String userName) {
      this.userName = userName;
  }
      .
      .
  </code></pre>
  
  <p><strong>SearchAction.java</strong></p>
  
  <pre><code>public ActionForward execute(ActionMapping mapping, ActionForm form,
          HttpServletRequest request, HttpServletResponse response) {
  
      SearchFB sfb = (SearchFB) form;
      Formdata fd = new Formdata();
      fd.setUserName((String) sfb.get("userName"));
      fd.setAge((Integer) sfb.get("age"));
      fd.setQualification((String)sfb.get("qualification"));
      fd.setCaste((String) sfb.get("caste"));
  
      SearchDTO sdto = new SearchDTO();
      SearchJB sjb = new SearchJB();
      sjb.searchProduct(sdto);
      return mapping.findForward("ssuccess");
  }
  }
  </code></pre>
  
  <p><strong>Formdata.java</strong></p>
  
  <pre><code>public Formdata extends ActionForm{        
  private String userName;
  private String qualification;
  private Integer age;
  private String caste;
  
  
  public String getUserName() {
      return userName;
  }
  public void setUserName(String userName) {
      this.userName = userName;
  }
      setters and getters...
  </code></pre>