Maan,
Going back to your snippet of code from the _jspService it's almost as if you'd looked in the
Tomcat Catalina work directory
Essentially with just a Type the container will try and retrieve an attribute of the specified name, and cast it to the type specified. Using normal servlet classes (as they are cleaner) the JSP becomes the equivalent of:
foo.Employee person = (foo.Employee) request.getAttribute("person");
If it can't find it, or the attribute it finds can't be cast that way, then it will throw an error!
With both a class and type specified i.e.
<jsp:useBean id="test" class="foo.Class" type="foo.Type" scope="request">
....
Your JSP becomes an equivalent of:
foo.Type
test = (foo.Type) request.getAttribute("test");
if (test==null){
test = new foo.Class();
}
So again it tries first to find the attribute and cast it to the specified type. Failing that it creates a new instance of class!
To add to the confusion I believe in early prints of the 2nd edition the answer to example 1 in the Be the container question (pg 420) is incorrect! i.e. HFSJ says it shouldn't work, except that it should as it can find the bean in the request scope and cast it to the specified type!
Does this help, or just confuse things further.
Rufus.