This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes jsp:useBean exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "jsp:useBean exception" Watch "jsp:useBean exception" New topic
Author

jsp:useBean exception

vani venkat
Ranch Hand

Joined: Nov 21, 2006
Posts: 142
hi,
i am trying an example of useBean standard action.

Here is my TestBean.jsp


and PrintBean.jsp



and my employee class



public class Employee {

private int empId;
private String name;

String getName(){
return this.name;
}

void setName(String n){
this.name = n;
}
int getEmpId(){
return this.empId;
}

void setEmpId(int n){
this.empId = n;
}

}


when i give values in testBean.jsp and click submit, i am getting org.apache.jasper.JasperException: Cannot find any information on property 'name' in a bean of type 'Employee'

can some one point out what is problem here. i checked naming conventions of employee bean. they seem to be fine.
thank you


SCJP 1.4, SCWCD 1.5
Dumitru Postoronca
Ranch Hand

Joined: May 06, 2008
Posts: 46
vani venkat wrote: <jsp:useBean id="person" class="Employee">


AFAIK, as of JSP 2.0, referring to any classes from the unnamed or default package is not allowed. Try storing your class in a package.
nizamuddin
Greenhorn

Joined: Oct 24, 2005
Posts: 4
lets know what exception you are getting......i mean some more information about the exception that you are receiving....try just see whats happening when you just add the bean than setting the property......may be something related to the method names being used....

vani venkat
Ranch Hand

Joined: Nov 21, 2006
Posts: 142
hi dumitru,
i moved employee bean to a package named foo.


and changed useBean tag to reflect package name


now i am getting
org.apache.jasper.JasperException: Cannot find any information on property 'name' in a bean of type 'foo.Employee'

vani venkat
Ranch Hand

Joined: Nov 21, 2006
Posts: 142
I am using JDK 1.5 and tomcat 5.
vani venkat
Ranch Hand

Joined: Nov 21, 2006
Posts: 142
hi nizamuddin
here is the stack trace.

org.apache.jasper.JasperException: Cannot find any information on property 'name' in a bean of type 'foo.Employee'
org.apache.jasper.runtime.JspRuntimeLibrary.getReadMethod(JspRuntimeLibrary.java:836)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1012)
org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:1063)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2164)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2214)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2220)
org.apache.jasper.compiler.Node$Root.accept(Node.java:457)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2164)
org.apache.jasper.compiler.Generator.generate(Generator.java:3322)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:199)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:296)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:299)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61314
    
  66

Please be sure to use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the button on your post.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61314
    
  66

Then carefully inspect your bean class. I saw the problem in seconds (even without the code tags).
vani venkat
Ranch Hand

Joined: Nov 21, 2006
Posts: 142
public getters and setters i think, i am going to try now.
vani venkat
Ranch Hand

Joined: Nov 21, 2006
Posts: 142
yes. public setters and getters resolved problem. thank you BB
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61314
    
  66

Bingo!
 
 
subject: jsp:useBean exception