title: Why do we typecast ActionForm object into our java form bean class in Action class in STRUTS?
body: <p>What i know: actionformbean that we create is a sub class of ActionForm</p>
  
  <p>Now let's suppose we create...
  Struts action form bean: productbean.java
  Struts action class:     productaction.java</p>
  
  <p>In productaction.java's <code>execute()</code> method:- I did</p>
  
  <pre><code>{
  productbean p1 = new productbean();
  String n =p1.getName();   // calling the getter, that returns the product name 
  }
  </code></pre>
  
  <p>But n is null, when written into database</p>
  
  <p>With this in <code>execute</code> method everything works fine:</p>
  
  <pre><code>{
  productbean p1 = (productbean)form; // downcasting of ActionForm object
  String n = p1.getName(); 
  }
  </code></pre>
  
  <p>My question is if actionclass and formbean are in same package, why can't we just create an object of the formbean and call its getter function in actionclass? Why downcasting of ActionForm object  is necessary?</p>