Hello Friends, here is a question from JPilot exam,
Which of the following are valid uses of the <jsp:useBean> action? A. <jsp:useBean id="myBean" class="MyBean" scope="session"> B. <jsp:useBean id="myBean" class="MyBean"/> C. <jsp:useBean id="myBean" class="MyBean" beanName="SomeOtherBean"/> D. <jsp:useBean id="myBean" type="MyBean">
My answers were A and B, but it says B and D.. why so? what is wrong with A??if you say A is not ending with a forward slash"/" but its the same with D. and why is D selected as correct ans?
As far as my knowledge goes, D is wrong since if only type attribute is specified without class attribute, then bean should exist already and hence jsp:useBean should have closing tag. Correct me if I am wrong.
I think A is incorrect only because of not having a closing tag. B is correct, C is incorrect because Class and beanName cannot exist together.D is correct and i dont think if a bean is already present as is the case with D, the tag should be closed.(They are 2 different things. If this is wrong pls let me know y?)
Hi, thanks for pointing that having a body and closing tags are two different things. I have doubt though. should not closing a tag mean using either if these options 1. </jsp:useBean> 2.specify /> at the end. (eg: <jsp:useBean id="name" class="" type="" />
In both options A and D none of these two forms exist. Then why is A incorrect for not having a proper closing tag where as D is correct even though it also doesnot have one closing tag?