• 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
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

problem with type attribute ....  RSS feed

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
friends .... type attribuite if used with out the class attribute gives me the follwoing exception ..... please guide as to where the problem is

SUPER CLASS
package com.example.model;
public abstract class DBNameForJSPSuper {
private String dbversion;
public void setDbversion(String version){
System.out.println("Inside setDbversion");
dbversion=version;
}
public String getDbversion(){
System.out.println("Inside getDbversion");
return dbversion;
}
}

SUBCLASS
package com.example.model;
public class DBNameForJSP extends DBNameForJSPSuper{
private String dbname="Deepinder";
public DBNameForJSP() {}
public void setDbname(String name){
System.out.println("Inside setDbname");
dbname=name;
}
public String getDbname(){
System.out.println("Inside getDbname");
return dbname;
}
}

JSP CODE
<jsp:useBean id="DBNameTest" class="com.example.model.DBNameForJSP" type="com.example.model.DBNameForJSPSuper"
scope="application" >
<jsp:setProperty name="DBNameTest" property="dbname" value="Singh" />
</jsp:useBean>

<br><br><b> The DB name stored in JSP is : </b>
<jsp:getProperty name="DBNameTest" property="dbname"/>

--> if above class attribute is ommitted then the foll. error msg comes

ERROR MESSAGE
org.apache.jasper.JasperException: Cannot find any information on property 'dbname' in a bean of type 'com.example.model.DBNameForJSPSuper'
org.apache.jasper.runtime.JspRuntimeLibrary.getReadMethod(JspRuntimeLibrary.java:837)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1013)
org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:1062)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Generator.generate(Generator.java:3269)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:244)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:470)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

Please help guys !!!
 
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its the basic thing the object will be of DBNameForJSP but the reference or type will be DBNameForJSPSuper, and DBNameForJSPSuper doesn't have that attribute in it, thats why you are getting the exception.

<jsp:useBean id="DBNameTest" class="com.example.model.DBNameForJSP" type="com.example.model.DBNameForJSPSuper"
scope="application" >
<jsp:setProperty name="DBNameTest" property="dbname" value="Singh" />
</jsp:useBean>


This code is equivalant to something like this;


Try this code without JSP, you will get the same exception that DBNameForJSPSuper doesn't have any information for "dbname" attribute.
 
Deepinder S Narang
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot for helping !
 
Why am I so drawn to cherry pie? I can't seem to stop. Save me tiny ad!
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!