Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About jsp:useBean

 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

i am using jsp:usebean in my jsp page.but Bean class is abstract.

when i try to use this
<jsp:useBean id="instanceofbean" class="package.Name">
<jsp:setProperty name="instanceofbean" property="name" value="kumar"/>
</jsp:useBean>

Exception is coming..i know it will works fine for non-abstract class..

for abstract class we have to mention "type" attribute insteadof class in usebean.i tried this also..but i am getting "bean must exist in scope"
error..

so ,please provid solution for useBean of abstract class .

thanks & regards,
seetharaman.v
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To use type, the bean must already exist in the specified scope. If the bean is to be created, it cannot be of an abstract class that cannot be instantiated.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Bear Bibeault,

thanks for reply. ....you said that...

" To use type, the bean must already exist in the specified scope."

fine..but how can i put the bean into the specified scope...sorry i cannot understand..please explain me in detail..

waitting for your earnest replay..

thanks & regards,
seetharaman
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you getting to the JSP? Are you forwarding to the JSP from a servlet controller? If so, you'd create the bean in the servlet and attach it to request scope prior to forwarding to the JSP.

If the JSP is the first thing in the request, then using type makes no sense unless it's for a bean that had been previously placed in session or application scope.

So what is it that you are actually trying to do?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Bear Bibeault,

this is my java class-->


public abstract class Ban{

Ban(){

}
protected String mobile;

protected String getMobile(){
return this.mobile;
}

protected void setMobile(String mob){
this.mobile=mob;
}

}



------> shortly,i want to use this abstract class(abstrat class can not be instatiated) into my jsp using useBean..what can i do for that...

------> i totally confused with this jsp:useBean's type attribute..

please send me the earnest reply in detail

thanks & regards,
seetharaman
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would you want to use an abstract class in your JSP?
Do you have subclasses of that bean that are concrete?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Ben,

thanks for reply, ok ...i will use concrete class which is extends abstract class ..

thanks & regards,

seetharaman
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want the jsp:useBean action to instanciate the concrete class, you'll need to use the 'class' attribute.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic