Hello. I have two JSPs and a JavaBean that aren't working. This is a problem that's probably very common to newbies, so please forgive me if this has been answered in this forum. I've Googled all over the place for an answer to this, and although I'm not the only one who's ever had this problem, I can't seem to figure out what my problem is.
I'm using Tomcat 6.0. The first JSP is GetName.jsp, located at C:\Tomcat\webapps\app1\GetName.jsp:
<HTML>
<BODY>
<FORM METHOD=POST ACTION="NextPage.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>
The second JSP is NextPage.jsp, located at C:\Tomcat\webapps\app1\NextPage.jsp:
<jsp:useBean id="user" class="classes.UserData" scope="session"/>
<HTML>
<BODY>
You entered<BR>
Name: <jsp:getProperty name="user" property="username" /><BR>
Email: <jsp:getProperty name="user" property="email" /><BR>
Age: <jsp:getProperty name="user" property="age" /><BR>
</BODY>
</HTML>
My JavaBean, UserData, compiles correcty, and the class file is located at C:\Tomcat\webapps\app1\WEB-INF\classes:
package classes;
import java.io.Serializable;
public class UserData implements Serializable {
String username;
String email;
int age;
public UserData() {
}
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; }
}
I also have the following in my web.xml file, located at C:\Tomcat\webapps\app1\WEB-INF:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
</web-app>
My Google searches have suggested something to do with the classpath. My classpath is currently .;C:\Tomcat\lib\servlet-api.jar.
When I enter information in GetName.jsp and click on the button, Tomcat gives me the following for NextPage.jsp:
org.apache.jasper.JasperException: /NextPage.jsp(1,1) The value for the useBean class attribute classes.UserData is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1203)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1160)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2393)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2399)
org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Generator.generate(Generator.java:3365)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:199)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:315)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
I could swear I'm doing everything right, but apparently I'm not. Could someone please tell me what's wrong before I tear all my hair out? Thanks in advance.