javax.servlet.ServletException

[nobr]Can someone help me out. I am new to JSPs

I trying to learn how to use javaBeans and JSPs and get the following errors (they alternate when I refresh the page)

javax.servlet.ServletException: sample/UserData (wrong name: UserData)

root cause

java.lang.NoClassDefFoundError: sample/UserData (wrong name: UserData)

or

org.apache.jasper.JasperException: Unable to loadclassfor JSP

root cause

java.lang.ClassNotFoundException: org.apache.jsp.my_005ffiles.first_005fbean_jsp

I have a class UserData

package sample;

publicclass UserData{

String txtUsername;

String txtPassword;

public UserData(){}

....

JSP Page

<body bgcolor="#ffffff">

<h1>Here is the bean data</h1>

<%-- Create and initialize bean --%>

<jsp:useBean id="user" class="sample.UserData">

<jsp:setProperty name="user" property="txtUsername" value="myname" />

</jsp:useBean>

User name: <c:out value="${user.txtUsername}" /><br/>

</body>

I altered the server.xml file

<Host name="localhost" appBase="C:\.....folder\appdir"

unpackWARs="true" autoDeploy="true"

deployOnStartup="true"

xmlValidation="false" xmlNamespaceAware="false">

<Context

path=""

docBase="C:\...folder\web"

crossContext="false"

debug="0"

reloadable="true">

</Context>

.......default rest of way

I store my UserData.class file in WEB-INF\classes\sample\

which is located in another sample webapp I got from the O'reilly site:

ora\

so my directory structure looks like

C:\......folder\ora\WEB-INF\classes\sample

UserData.class

C:\.....folder\ora\my_files

first_bean.jsp

Does anyone know what is going on?

If you need more info, I will provide.

Thanks[/nobr]

[2750 byte] By [jwstudenta] at [2007-10-2 15:58:48]
# 1

Sorry my directory structure looks like this:

C:\......folder\appdir\ora\WEB-INF\classes\sample

UserData.class

C:\.....folder\appdir\ora\my_files

first_bean.jsp

I am using Tomcat as server.

Does anyone know what is going on?

If you need more info, I will provide.

Thanks

jwstudenta at 2007-7-13 16:24:01 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 2

Everything looks ok.

The error message "wrong name: UserData" would normally indicate that you have the class name mainly right, but are not matching the exact case of the class involved. is it Userdata or something like that?

Check that class.Is it in the right package?

Try recompiling that class, and replacing the class file.

Restart Tomcat (changes to class files don't take immediately. Requires restart)

Does a simple "Hello world" JSP work?

evnafetsa at 2007-7-13 16:24:01 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 3
Yes Hello.jsp worksMaybe there is something with the way I compile my class?C:\........src> javac sample\UserData.javawhere my files are located inC:\........src\sampleUserData.java
jwstudenta at 2007-7-13 16:24:01 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 4
Thanks,I recompiled and it worked.
jwstudenta at 2007-7-13 16:24:01 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...