wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Is this answer right? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Is this answer right?" Watch "Is this answer right?" New topic
Author

Is this answer right?

Sreeraj G Harilal
Ranch Hand

Joined: Apr 19, 2006
Posts: 310
Book - HFSJ
Chapter - 8
Page - 430
Question - 11

Which are true about the <jsp:useBean> standard action?

A. The id attribute is optional.
B. The scope attribute is required.
C. Then scope attribute is optional and defaults to request.
D. Either the class or type attributes may be specified,
but atleast one.
E. It is valid to include both the class attribute and the type attribute, even if their values are NOT the same.

The answer ticked was D and E.
Is it right?
I think only the option E is write.
Please clear my doubt.


SCJP 5.0<br />SCWCD 1.4<br />Preparing for <b>SCEA</b>.<br /><b>"I prefer an interesting vice to a virtue that bores."</b>
Dilshan Edirisuriya
Ranch Hand

Joined: Apr 22, 2006
Posts: 299
D is also right. You have to use either type or class. But when you are using beanName attribute you have to use type and it's mandetory.


Dilshan Edirisuriya SCJP1.4, SCWCD1.4, SCBCD 5
Sreeraj G Harilal
Ranch Hand

Joined: Apr 19, 2006
Posts: 310
Why don't we use both class and type attribute in a <jsp:useBean>?

I am sure D is Wrong.
Celinio Fernandes
Ranch Hand

Joined: Jun 28, 2003
Posts: 547

D is not wrong at all.
Read the chapter again, your answer is there.


SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCBCD 5
Visit my blog
Sayak Banerjee
Ranch Hand

Joined: Nov 28, 2006
Posts: 292
Yeah...D is correct....go htrough the topic once again and I hope your doubt will be cleared


Turn on, tune in, drop out.
Renu Radhika
Ranch Hand

Joined: Oct 21, 2005
Posts: 243
They have specified it as either type or class may be specified and atleast one.They have not told that both cant be used together.I hope I am clear.

either both
or one but atleast one
Sreeraj G Harilal
Ranch Hand

Joined: Apr 19, 2006
Posts: 310
Yes Radhika, i got it
Sreeraj G Harilal
Ranch Hand

Joined: Apr 19, 2006
Posts: 310
Either the class or type attributes may be specified, but atleast one.

But it is really a foolish statement,isn't it?
A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 979
It means that ..

1) if type is only declared..then the bean must already be there
we cannot create a new bean if it doesnt exists with only type mentioned
2) if class is only declared it is fine whether bean exists or needs to be created
3) if both are there,it is fine..
Same as above
Sreeraj G Harilal
Ranch Hand

Joined: Apr 19, 2006
Posts: 310
Is there any possibility of someone using class attribute twice like :-

<jsp:useBean id="person" class="foo.Person" class="foo.Person"/>

then why they are saying "atleast one"
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42050
    
  64
Originally posted by Sreeraj G H:
Is there any possibility of someone using class attribute twice like :-

<jsp:useBean id="person" class="foo.Person" class="foo.Person"/>

then why they are saying "at least one"


"At least one" does not mean "one or more class attributes", it means "a class or type attribute, but at least one of them". Thus, more than one class attribute would be incorrect.


Ping & DNS - my free Android networking tools app
Sreeraj G Harilal
Ranch Hand

Joined: Apr 19, 2006
Posts: 310
Please read the question carefully

Which are true about the <jsp:useBean> standard action?

A. The id attribute is optional.
B. The scope attribute is required.
C. Then scope attribute is optional and defaults to request.
D. Either the class or type attributes may be specified,
but atleast one.
E. It is valid to include both the class attribute and the type attribute, even if their values are NOT the same.



"At least one" does not mean "one or more class attributes", it means "a class or type attribute, but at least one of them". Thus, more than one class attribute would be incorrect.


MY POINT IS OPTION D IS WRONG.BECAUSE WE MAY USE TYPE AND CLASS TOGETHER.
AM I RIGHT?
Sreeraj G Harilal
Ranch Hand

Joined: Apr 19, 2006
Posts: 310
Can anyone give explanation of option D with a small example.
please...............

Because my mind says its a wrong statement.
Sreeraj G Harilal
Ranch Hand

Joined: Apr 19, 2006
Posts: 310
We can use <jsp:useBean ....> without type or class using beanName.
Till chapter they are not specified about beanName property.Maybe because of that option D is correct.
Siddharth Purandare
Ranch Hand

Joined: Nov 13, 2006
Posts: 101
Hi all,

Here is the extract from the Hanumant singh's book. Its very properly defined there please have a look and let me know if you guys can understand this:::

With <jsp:useBean> we can use attributes as below:

A. id which is mandatory.
B. scope which is optional
C. We can use 4 combinations only with the below 3 attributes:
(i) Class
(ii) Type Out of (i)and (ii) atlease 1 is mandatory.
(iii) class and type
(iv) beanName and type

These are the only valid combinations!!! I hope this solves all the doubts and also it will be a good information to share with all you guys. Make a note of this.

Cheers!!!


Siddharth Purandare<br />SCJP 1.4 - 76%<br />SCWCD 1.4 - 85%<br /> <br />It is the "attitude" and not the "aptitude" which determines "altitude".
Anitha Srinivasan
Ranch Hand

Joined: Nov 07, 2006
Posts: 53
Sreeraj here u go,

<jsp:userBean id="name" scope="page|request|session|application" beandetails />

id - mandatory
scope - optional , default page

beandetails

class ="classname"
class="classname" type="typename"
beanname="beanname" type="typename"
type="typename"

type - superclass, interface, class
class -fully qulified name(package), Must not be a abstract class
beanName - name of a bean , attribute can refer to a class

Here is the coimbination,

1. beanName and class can't be together.
2. Atleast one of type and class MUST be present.
3. type can be alone or in combiantion with class or beanName

4.If type is used without the class, the bean must be present, else InstantiationExcpetion is raised if the object is not found.
If the the object is in wrong class ClasscastException raised.


I think i am clear , Pls correct me if some one has more points.

Thanks,
Anitha
Sreeraj G Harilal
Ranch Hand

Joined: Apr 19, 2006
Posts: 310
Ok now i am clear.
We must use atleast type or class property with <jsp:useBean ..>.
My thought was, we can use <jsp:useBean > with the combination beanName & id property.
But now i am clear that we can use beanName property only with type property.

Thanks for all.
 
GeeCON Prague 2014
 
subject: Is this answer right?