Hi folks,
I am confused about beans. I think it has to
do with the CLASSPATH and my lack of understanding
for sure. My platform is a linux machine with
tomcat 6.0.14. Here's the lay of the land.
Under $CATALINA_HOME/webapps/ I have created
a directory called my-jsp, in which there are
three files:
GetName.html
SaveName.jsp
UserData.java
GetName.html looks like:
<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> <P>
<INPUT TYPE=SUBMIT>
</FORM>
</BODY>
</HTML>
SaveName.jsp looks like:
<jsp:useBean id="user" class="user.UserData" scope="session"/>
<jsp:setProperty name="user" property="*"/>
<HTML>
<BODY>
You entered <BR>
Name: <%= user.getUsername() %> <BR>
Email: <%= user.getEmail() %> <BR>
</BODY>
</HTML>
And UserData.java looks like:
package user;
public class UserData {
String username;
String email;
public void setUsername( String value ) {
username = value;
}
public void setEmail( String value ) {
email = value;
}
public String getUsername() {
return username;
}
public String getEmail() {
return email;
}
}
UserData.java compiles fine. I moved UserData.class file
into $CATALINA_HOME/common/lib/user directory. My CLASSPATH
variable says:
CLASSPATH=/usr/local/src/apache-tomcat-6.0.14/common/lib:and-on-and-on
When I point my browser to http://myhost:8080/my-jsp/GenName.html,
I get a form, which I fill and press the submit button. Here's what
happens:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it
from fulfilling this request.
exception
org.apache.jasper.JasperException: /SaveName.jsp(1,1) The value for the
useBean class attribute user.UserData is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
(and a few more lines I am omitting)
I think the complaint is about the first line of SaveName.jsp:
<jsp:useBean id="user" class="user.UserData" scope="session"/>
I have stared at this for a long, long minutes, but I see nothing wrong.
Can somebody please clue me in as to what I am doing wrong?
Many thanks in advance.
Regards,
Tena Sakai