| Author |
About jsp:useBean
|
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
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
Joined: Jan 10, 2002
Posts: 56233
|
|
|
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.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
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
Joined: Jan 10, 2002
Posts: 56233
|
|
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
Joined: Jan 28, 2008
Posts: 5575
|
|
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
Joined: Dec 11, 2004
Posts: 13410
|
|
Why would you want to use an abstract class in your JSP? Do you have subclasses of that bean that are concrete?
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
hi Ben, thanks for reply, ok ...i will use concrete class which is extends abstract class .. thanks & regards, seetharaman
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
|
If you want the jsp:useBean action to instanciate the concrete class, you'll need to use the 'class' attribute.
|
 |
 |
|
|
subject: About jsp:useBean
|
|
|