I am not sure where in the jsp specification that was mentioned.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
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>