Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Problem in Scriptless JSPs

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends...

My form.html:
<html>
<body>

<h1 align="center"> JSLTPage </h1>
<form method="POST" action="result.jsp">
Name : <input type="text" name="empName">
ID# : <input type="text" name="empID">
<input type="SUBMIT">
</form>
</body>
</html>
===================================================================
Person class :
package foo;
public abstract class Person {
String empName;

public String get_empName()
{ return empName;
}
public void set_empName(String s)
{ empName=s;

}
}
=====================================================================
Employee Class :

package foo;
public class Employee extends Person{
String empID;

public String get_empID()
{ return empID;
}
public void set_empID(String s)
{ empID=s;

}
}
========================================================================
my result.jsp

<html>
<body>
<jsp:useBean id="person" type="foo.Person" class="foo.Employee" scope="request">
<jsp:setProperty name="person" property="*" />
</jsp:useBean>
Person Created by Servlet : <jsp:getProperty name="person" property="empName"/>
Person Created by Servlet : <jsp:getProperty name="person" property="empID"/>
</boby>
</html>
==========================================================================
My error :



HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Cannot find any information on property 'empName' in a bean of type 'foo.Employee'
at org.apache.jasper.runtime.JspRuntimeLibrary.getReadMethod(JspRuntimeLibrary.java:871)
at org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:958)
at org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:974)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2017)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2059)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2065)
at org.apache.jasper.compiler.Node$Root.accept(Node.java:423)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2017)
at org.apache.jasper.compiler.Generator.generate(Generator.java:2907)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:291)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:458)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:444)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:593)

.......................................... and so on...............
=========================================================================

I dont understand, why m unable to access my empName from employee class???

Please help me out....

thanks...
pooja
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi puja,
the probelm is with the bean code.change it as below


===================================================================
Person class :
package foo;
public abstract class Person {
String empName;

public String getEmpName()
{ return empName;
}
public void setEmpName(String s)
{ empName=s;

}
}
=====================================================================
Employee Class :

package foo;
public class Employee extends Person{
String empID;

public String getEmpID()
{ return empID;
}
public void setEmpID(String s)
{ empID=s;

}
}
 
Puja Verma
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thankx .....
its working now

but i dint get it , why was the problem in giving function name with underscore ???
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
This is from kathy's book HFServlet...p344
..., the name of the property is what you get when you strip off the prefix "get" and "set, and make the first character after that lower case. So, getName/setName become name.
So your one would be _empID after stripped.
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic