please help me
head fist
jsp and
servlet 2nd edition book
page no: 358
Question is :
Look at this standard action:
<jsp:useBean id=”person” type=”foo.Employee” scope=”request” >
<jsp:setProperty name=”person” property=”name” value=”Fred” />
</jsp:useBean >
Name is: <jsp:getProperty name=”person” property=”name” />
Now imagine that is Servlet does some work and then forwards the request to the JSP that has the code above. Figure out what the JSP code above would do for each of the three different servlet code examples. (The answer is given at the page no : 420)
foo.Person p = new foo.Employee();
p.setName(“Evan”);
request.setAttribute(“person”, p);
answer is :
Fails 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.
my prob :
sinch the "person" attribute already exists in request scope that is set by servlet code.
then why it will fail at request time.
but why <jsp:useBean> tag won't work.
i have studied in page no : 356 of 2nd edition head first jsp & servlet book that
heading
using type without class
if the persn attribute already exists in that scope
it works perpectly
and
if the person attribute does not exist in that scope
then java.lang.InstantiationException: bean person not fund within socpe
please explain. why this discrepancy happens.
it shoud work why fail at request time.