org.apache.jasper.JasperException: Cannot find any information on property in a bean of type

This is my bean class,

package com.saravanan.domain;

public class Student {
 
 String StudentName;

 public String getStudentName() {
  return StudentName;
 }

 public void setStudentName(String studentName) {
  StudentName = studentName;
 }

}

 
The below is my servlet’s doGet() method logic,

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  Student st = new Student();
  st.setStudentName(“saravanan”);
  request.setAttribute(“student”, st);
  RequestDispatcher rd = request.getRequestDispatcher(“/display.jsp”);
  rd.forward(request, response);
 }

 
The below is my display.jsp that renders the content using jsp:useBean standard action tag,
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=ISO-8859-1″>
<title>display page</title>
</head>
<body>
<jsp:useBean id=”student” scope=”request”/>
<jsp:getProperty name=”student” property=”StudentName”/>
</body>
</html>

 
I got below error,

 
org.apache.jasper.JasperException: Cannot find any information on property ‘StudentName’ in a bean of type ‘com.saravanan.domain.Student’
 org.apache.jasper.runtime.JspRuntimeLibrary.getReadMethod(JspRuntimeLibrary.java:824)
 org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1075)
 org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:1126)
 org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
 org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
 org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434)
 org.apache.jasper.compiler.Node$Root.accept(Node.java:475)
 org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
 org.apache.jasper.compiler.Generator.generate(Generator.java:3489)
 org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:250)
 org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
 org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
 org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
 org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
 com.csc.ssivaji.controllers.StudentServlet.doGet(StudentServlet.java:37)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

 
The issue here is, Bean property names begin with lowercase letters,  It is potentially confusing that the initial lowercase letter by convention appears uppercase in

getter and setter names; for example, getStundentName() and setStudentName(String) would be the getter and setter for property “studentName”.

If Jasper couldn’t find the bean class then it would have said so; if it goes so far as to check the presence of a particular property then it has already introspected the bean class.

Doesnt matter if you created your properties in uppercase, but it is recommended that you have to makesure that property is in lower case.

 
Solution to fix the problem:

change property=”StudentName” to property=”studentName”

 

like below,

 

<jsp:useBean id=”student” scope=”request”/>
<jsp:getProperty name=”student” property=”studentName”/>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: