1

I am getting a The value for the useBean class attribute user.CompileClasss is invalid These are my files:

index.jsp

<%@ page session="true" %>
<%@ page import="user.CompileClass" %>

<jsp:useBean id="user1" class="user.CompileClasss" scope="session" />
<jsp:setProperty name="user1" property="*"/>
<html>  
  <body>
    <FORM METHOD=POST ACTION="Result.jsp">
What's your name? <INPUT TYPE=TEXT NAME=uname 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>

CompileClass.java

package user;

public class CompileClass {
    public String uname;
    public String mail;
    public int age;

    /*public CompileClass(String uname, String mail, int age) {
        this.uname=uname;
        this.mail=mail;
        this.age=age;
    }*/ 
    public CompileClass(){
    }



    public String returnname(){
        return uname;
    }
    public String   returnmail(){
        return mail;
    }
    public int returnage(){
        return age;
    }


/*public void main()
{


}*/
}

Result.jsp

<jsp:useBean id="user1" scope="session" class="user.CompileClass" />
<html>

  <body>
   You entered:<BR>

Name: <%= user1.returnname() %>  <BR/> 
Email: <%= user1.returnmail() %><BR>
Age: <%= user1.returnage() %><BR>
  </body>
</html>

Any help?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Anurag
  • 723
  • 3
  • 13
  • 31
  • Why did you accept an answer which doesn't answer the concrete problem "The value for the useBean class attribute user.CompileClasss is invalid" at all? Having `jsp:setProperty` in the wrong page has nothing to do with it. – BalusC Mar 24 '11 at 17:18
  • @BalusC I accepted it as my whole code was too messed up and was wrong and that answer solved my one problem in the re-written code. – Anurag Mar 24 '11 at 18:58
  • Your initial question as you stated in the title and the question body "error: The value for the useBean class attribute user.CompileClasss is invalid" isn't answered with this and hence the answer is not useful and misleading for others who stumble upon this question by Googling on the error message. – BalusC Mar 24 '11 at 19:17

3 Answers3

1

You have wrong JavaBean format. Read this article for explanations.

UPDATE: wrong format of JavaBean broke this line of your code:

<jsp:setProperty name="user1" property="*"/>

Application server cannot find mapping between form's params and fields of your bean.

And there is another problem, you should place

<jsp:setProperty name="user1" property="*"/>

into Result.jsp, because there is no defined properties, when Index.jsp are running.

ilalex
  • 3,018
  • 2
  • 24
  • 37
  • I accept it is not in proper format as described on Wikipedia but does that mean it won't work. Mind explaining a bit? – Anurag Mar 24 '11 at 11:47
  • out of all that you pointed, I think this is the main culprit. I should put `` in Result.jsp to make it work. Thanks. – Anurag Mar 24 '11 at 16:45
1

The value for the useBean class attribute user.CompileClasss is invalid

This one is equal to a ClassNotFoundException. And indeed, you have one s too much in the classname.

Replace

class="user.CompileClasss"

by

class="user.CompileClass"

Unrelated to the concrete problem, that @page import is completely unnecessary. Remove it. Your class also doesn't adhere the Javabeans specification. The getter methods needs to be prefixed with get, fix it accordingly. You can also not access it using scriptlets <% %>. Use EL ${} instead.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
0

i think you didn't place the compiled class.

javanna
  • 59,145
  • 14
  • 144
  • 125
developer
  • 9,116
  • 29
  • 91
  • 150
  • I am using MyEclipse and it is placed correctly as I checked from the folder structure via explorer. – Anurag Mar 24 '11 at 11:49