title: struts error- org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find bean
body: <p>I am trying out a simple struts application that will pass a String value from a java class file to a jsp.</p>
  
  <p>Here the corresponding files of the struts application-</p>
  
  <p>web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  
  &lt;!DOCTYPE web-app    PUBLIC
      "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
      "http://java.sun.com/dtd/web-app_2_3.dtd"&gt;
  
  &lt;web-app&gt;
  
      &lt;display-name&gt;Hello World Struts Application&lt;/display-name&gt;
  
      &lt;servlet&gt;
          &lt;servlet-name&gt;action&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.apache.struts.action.ActionServlet&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;config&lt;/param-name&gt;
              &lt;param-value&gt;/WEB-INF/struts-config.xml&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;debug&lt;/param-name&gt;
              &lt;param-value&gt;3&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;init-param&gt;
               &lt;param-name&gt;detail&lt;/param-name&gt;
               &lt;param-value&gt;3&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;action&lt;/servlet-name&gt;
          &lt;url-pattern&gt;*.do&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
  
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;view.jsp&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>struts-config.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt;
  
  &lt;!DOCTYPE struts-config PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
          "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"&gt;
  &lt;struts-config&gt;
  
      &lt;form-beans&gt;
          &lt;form-bean name="myForm" type="com.myForm" /&gt;
      &lt;/form-beans&gt;
  
      &lt;action-mappings&gt;
          &lt;action path="/view" scope="request" name="myForm" type="com.myAction" validate="false"&gt;
                  &lt;forward name="success" path="/first" /&gt;
          &lt;/action&gt;
          &lt;action path="/view"
                  forward="/view.jsp"/&gt;
          &lt;action path="/first"
                  forward="/first.jsp" /&gt;
      &lt;/action-mappings&gt;
  &lt;/struts-config&gt;
  </code></pre>
  
  <p>view.jsp</p>
  
  
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
          &lt;form action="first.do"&gt;
              Enter name :
              &lt;input type="text" name="name"/&gt;
              &lt;input type="submit" value="Enter"/&gt;
          &lt;/form&gt;
  
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>first.jsp</p>
  
  <pre><code>&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  &lt;%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %&gt;
  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
          Welcome!!!!!!!!
  
          &lt;bean:write name="myForm" property="st"/&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>myForm.java</p>
  
  <pre><code>package com;
  
  import javax.servlet.http.HttpServletRequest;
  
  public class myForm extends org.apache.struts.action.ActionForm {
  
      private String st;
  
      public String getSt()
      {
          return st;
      }
  
      public void setSt(String st)
      {
          this.st=st;
      }
  
      public myForm(String st)
      {
          this.st=st;
      }
  }
  </code></pre>
  
  <p>myAction.java</p>
  
  <pre><code>package com;
  
  import java.io.IOException;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import org.apache.struts.action.Action;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  
  
  public class myAction extends org.apache.struts.action.Action {
      public ActionForward execute(ActionMapping mapping, ActionForm form,
      HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {
  
          myForm form1=(myForm) form;
  
          String s="Karthikeyan";
  
          System.out.println("Hello "+s);
  
          form1.setSt(s);
  
          //RequestDispatcher reqDispatcher = getRequestDispatcher("view.jsp");
          //reqDispatcher.forward(request,response);
  
  
  
  
          return (mapping.findForward("success"));
      }
  }
  </code></pre>
  
  <p>Even though I have set the classpath for the class files, I get the following error when I compile myAction.java-</p>
  
  <pre><code>myAction.java:18: cannot find symbol
  symbol  : class myForm
  location: class com.myAction
                  myForm form1=(myForm) form;
                  ^
  myAction.java:18: cannot find symbol
  symbol  : class myForm
  location: class com.myAction
                  myForm form1=(myForm) form;
                                ^ 
  </code></pre>
  
  <p>When I try to execute the application on a web browser, I get the following error-</p>
  
  <pre><code>org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find bean: "myForm" in any scope
  </code></pre>
  
  <p>I have stuck on this issue for quite sometime without any solution. Please help me out.</p>