3 Replies Latest reply on Apr 24, 2005 2:35 PM by MiriTheQuiet

    Unable to compile class for JSP.

    sendres2 Newbie

      I want to test my configuration (JBOSS 3.2.3) with a very simple HTML form > JSP > bean example. The code I'm using is:

      HTML Page to collect information

      <HTML>
      <BODY>
      <FORM METHOD=POST ACTION="SaveName.jsp">
      What's your name? <INPUT TYPE=TEXT NAME=username SIZE=20><BR>
      What's your e-mail address? <INPUT TYPE=TEXT NAME=email SIZE=20><BR>
      What's your age? <INPUT TYPE=TEXT NAME=age SIZE=4>
      <P><INPUT TYPE=SUBMIT>
      </FORM>
      </BODY>
      </HTML>
      


      Java Bean to get information:
      public class UserDataBean {
       String username;
       String email;
       int age;
      
       public void setUsername( String value )
       {
       username = value;
       }
      
       public void setEmail( String value )
       {
       email = value;
       }
      
       public void setAge( int value )
       {
       age = value;
       }
      
       public String getUsername() { return username; }
      
       public String getEmail() { return email; }
      
       public int getAge() { return age; }
      }
      


      JSP to display informtion:
      <jsp:useBean id="user" class="UserDataBean" scope="session"/>
      <HTML>
      <BODY>
      You entered<BR>
      Name: <%= user.getUsername() %><BR>
      Email: <%= user.getEmail() %><BR>
      Age: <%= user.getAge() %><BR>
      </BODY>
      </HTML>
      


      As you can see, this is a VERY simple example. However, when I build it into a .war file and view it from a browser, I'm getting the following error:

      org.apache.jasper.JasperException: Unable to compile class for JSP
      
      An error occurred at line: -1 in the jsp file: null
      
      Generated servlet error:
       [javac] Compiling 1 source file
       [javac] C:\JBoss\jboss-3.2.3\server\default\work\MainEngine\localhost\MetaDataRepository2\JSP\SaveName_jsp.java:41: cannot resolve symbol
       [javac] symbol : class UserDataBean
       [javac] location: class org.apache.jsp.SaveName_jsp
       [javac] UserDataBean user = null;
       [javac] ^
       [javac] C:\JBoss\jboss-3.2.3\server\default\work\MainEngine\localhost\MetaDataRepository2\JSP\SaveName_jsp.java:43: cannot resolve symbol
       [javac] symbol : class UserDataBean
       [javac] location: class org.apache.jsp.SaveName_jsp
       [javac] user = (UserDataBean) pageContext.getAttribute("user", PageContext.SESSION_SCOPE);
       [javac] ^
       [javac] C:\JBoss\jboss-3.2.3\server\default\work\MainEngine\localhost\MetaDataRepository2\JSP\SaveName_jsp.java:46: cannot resolve symbol
       [javac] symbol : class UserDataBean
       [javac] location: class org.apache.jsp.SaveName_jsp
       [javac] user = (UserDataBean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "UserDataBean");
       [javac] ^
       [javac] 3 errors
      


      It seems to not create an instance of the bean class. I've checked the .war file, and the .java bean class is compiling and is located in the correct (WEB-INF/classes) directory. Any thoughts? Thanks in advance.