This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp:useBean exception

 
vani venkat
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Dumitru Postoronca
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using JDK 1.5 and tomcat 5.
 
vani venkat
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then carefully inspect your bean class. I saw the problem in seconds (even without the code tags).
 
vani venkat
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public getters and setters i think, i am going to try now.
 
vani venkat
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes. public setters and getters resolved problem. thank you BB
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bingo!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic