Page 1 of 1

About Question enthuware.jwpv6.2.948 :

Posted: Sun Jul 16, 2017 1:07 pm
by RumiJal
You mentioned in you explanation that :
2. If the scope attribute is not specified in useBean, it looks for the bean in all the scopes starting from page, request, session, and up to application
I am not sure where in the jsp specification that was mentioned.

If the scope attribute is not mentioned it looks for the bean in page scope (default scope) only, if the bean is not found a new instance is created and set as a page scope attribute.

Tested the following code with Tomcat and Glassfish and they both created a new instance of the bean an hence the <jsp:useBean> body is evaluated.

Code: Select all

<% 

	com.bean.Dog myDog = new com.bean.Dog();
	myDog.setName("rex");
	application.setAttribute("dog", myDog);

%>
 <jsp:useBean id="dog" class="com.bean.Dog" >
	In useBean body<br/>

</jsp:useBean> 

Re: About Question enthuware.jwpv6.2.948 :

Posted: Sun Jul 16, 2017 9:59 pm
by admin
You are right. The default value of scope is page and so it looks for the bean only in page scope.
This has now been updated.

thank you for your feedback!
Paul.