This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
and before this, I have the following code in my servlet running before forwarding the request to JSP:
foo.Person p = new foo.Employee();
in which foo.Person is an abstract class and foo.Employee extends it, assuming they both works quite all right with the proper getter and setter.
I don't understand why these code would fail during request time according to the answer. It seems to me that the servlet code have set the "person"
attribute at "request" scope which can be later fetched by the <jsp:useBean...>
It would help to know in what way it fails. Do you get an error message? A stack trace? Those are important information for anybody who wants to understand the problem.
Joined: Jul 18, 2012
frankly, this is a book example, I haven't rewrite the complete code and test it yet.
But according to the book, it says" it will FAIL at request time! The "person" attribute is stored at request scope, so the <jsp:useBean> tag won't work since it specifies only a type. The Container KNOWS that if you have only a type specified, there MUST be an existing bean attribute of that name and scope".
It seems to me the "person" attribute in the "request" scope is perfectly legal, so...I just don't understand the explanation...