Eshu Ravi

Greenhorn
+ Follow
since Sep 15, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Eshu Ravi

In my earlier post i had asked abt a mistake from the book HF servlets & JSP(authors basham,kathy,bates).i did not get a reply.

Hope i get a reply from the author atleast for this:

In chapter8 from HF servlets & JSP there is an exercise named "Be the Container" which has the following question..

Look at this standard action:
<jsp:usebean id="person" type="foo.Employee">
<jsp:setProperty name="person" property="name" value="Fred"/>
</jsp:usebean>
Name is:<jsp:getProperty name="person" property="name" />


what would the above jsp evaluate to if the servlet code looks in the following three different ways?Assume that foo.Person is an abstract class and foo.Employee is a concrete class that extends foo.Person.

1.
foo.Person p= new foo.Employee();
p.setName("Evan");
request.setAttribute("person",p);

2.
foo.Person p = new foo.Person();
p.setName("Evan");
request.setAttribute("person",p);

3.
foo.Employee p = new foo.Employee();
p.setName("Evan");
request.setAttribute("person",p);


Answers given in the book were:

With the first servlet code the request fails at request time since the perrson attribute is stored at request scope,also the jsp:usebean body will not be executed since it specifies only a type attribute.

with the second servlet code it said it fails to compile as foo.Person is abstract.

with the third servlet code it was given like this..The code works fine and prints "Evan".


My question is: Isn't the situation with the first servlet code and third servlet code the same? why has the author given that the third code works fine?where as the first servlet code fails.

Note that the jsp:usebean action does not have a scope attribute which means the default scope-page.but the person attribute is set in the request scope.

can the author or anyone else pls give me an explaination on this question.
correct me if im wrong..pls

thanks
Im referring to Head First Servlets & JSP ...In chapter7 coffee cram question no.6 says:

<%@ page isELIgnored="true" %>
what is the effect ?

Options:
1.Nothing ,this page directive is not defined.
2.The directive turns off the evaluation of Expression language code by the JSp container in all of the web application's JSp
3.The JSp containing this directive should not have any Expression Language code evaluated by the container.
4.The JSP containing this directive will only turn off the EL if the DD declares a <el-ignored>true</el-ignored> element with a url patttern that includes this JSp


the answer i thought was 3.but the book says it's option 4.
can anyone explain this

Thanks