About Question enthuware.jwpv6.2.948 :

Moderator: admin

Post Reply
RumiJal
Posts: 9
Joined: Wed Jul 12, 2017 10:51 am
Contact:

About Question enthuware.jwpv6.2.948 :

Post 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> 

admin
Site Admin
Posts: 10034
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.948 :

Post 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.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests