[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.4

JSP error:    java.lang.NoClassDefFoundError: user/UserData (wrong name: UserData)

Asked by vrosas_03 in Miscellaneous Web Development, Java Server Pages (JSP)

I've looked all over and always find the same solution to this exact tutorial (http://www.jsptut.com/Forms.jsp) but it it doesn't work for me.   The main answer for this is to put the class into the WEB-INF\classes\user  directory.  However in Tomcat there are several WEB-INF directories  (I think seven)  I put the class into all of them but it still doesnt work.  

here's the error:
javax.servlet.ServletException: java.lang.NoClassDefFoundError: user/UserData (wrong name: UserData)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:275)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

java.lang.NoClassDefFoundError: user/UserData (wrong name: UserData)
      java.lang.ClassLoader.defineClass1(Native Method)
      java.lang.ClassLoader.defineClass(Unknown Source)
      java.security.SecureClassLoader.defineClass(Unknown Source)
      org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1850)
      org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:890)
      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1354)
      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
      org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1247)
      org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1178)
      org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
      org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
      org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2417)
      org.apache.jasper.compiler.Node$Root.accept(Node.java:495)
      org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
      org.apache.jasper.compiler.Generator.generate(Generator.java:3426)
      org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:216)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:332)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
      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)
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
GetName.jsp
 
<HTML>
<BODY>
<p><FORM METHOD=POST ACTION="SaveName.jsp">
What's your name? <INPUT TYPE=TEXT NAME=username SIZE=20><br/>
What's your email address? <INPUT TYPE=TEXT NAME=email SIZE=20><br/>
What's your age? <INPUT TYPE=TEXT NAME=age SIZE=20><br/>
</p><INPUT TYPE=SUBMIT>
 
</FORM>
</BODY>
</HTML>
 
 
 
SaveName.jsp file:
 
<jsp:useBean id="user" class="user.UserData" scope="session"/>
<jsp:setProperty name="user" property="*"/> 
<HTML>
<BODY>
<A HREF="NextPage.jsp">Continue</A>
</BODY>
</HTML>
 
 
UserData.java file which I compiled into a class:
 
package user;
 
public class UserData {
 
    String username;
    String email;
    String age;
 
    public void setUsername( String value )
    {
        username = value;
    }
 
    public void setEmail( String value )
    {
        email = value;
    }
 
   public void setAge( String value )
    {
        age = value;
    }
 
    public String getUsername() { return username; }
 
    public String getEmail() { return email; }
 
    public String getAge() { return age; }
 
}
 
NextPage.jsp
 
<jsp:useBean id="user" class="user.UserData" scope="session"/> 
<HTML>
<BODY>
You entered<BR>
Name: <%= user.getUsername() %><BR>
Email: <%= user.getEmail() %><BR>
Age: <%= user.getAge() %><BR>
</BODY>
</HTML>
[+][-]09/07/09 04:45 PM, ID: 25277889Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Miscellaneous Web Development, Java Server Pages (JSP)
Sign Up Now!
Solution Provided By: vrosas_03
Participating Experts: 0
Solution Grade: A
 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20080625