File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes HFSJ doubt :Pg:356 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "HFSJ doubt :Pg:356" Watch "HFSJ doubt :Pg:356" New topic

HFSJ doubt :Pg:356

georgy jacob
Ranch Hand

Joined: Nov 23, 2005
Posts: 53
This qn is taken from HFSJ book Pg:356

Consider that employee is a concrete class which implements abstract class Person

<jsp:useBean id="person" type="foo.employee">
<jsp:setProperty name="person" property ="name" value="Fred"/>

Imagine the servlet forwards the request to the above Jsp. Fig out what the Jsp would do for each version of the servlets.

what happens if the servlet code looks like

1) foo.Person p = new foo.Employee();

ans: Fails at request time as the person attribute is stored at request scope while the jsp uses page scope.

2) foo.Employee p = new foo.Employee();

works fine

But in servlet code 2) as wel the attrbute is stored at request scope.. I am not getting this point. Shouldnt a compiler error be thrown again. Please help
Indunil Dasanayaka

Joined: Dec 12, 2005
Posts: 11
jacob I think u r right.

Shit Happens...
georgy jacob
Ranch Hand

Joined: Nov 23, 2005
Posts: 53
But i dont think an error will be there in the book.. I guess we understood the concept a little differently.. By the way i meant that a error will occur during request(run time) and it will not be a compiler error
Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026
Check the Errata section here

Page: 416

Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
georgy jacob
Ranch Hand

Joined: Nov 23, 2005
Posts: 53
Thanks vishnu . The errata section u provided was really useful
I agree. Here's the link:
subject: HFSJ doubt :Pg:356
Similar Threads
Bean related exercise question
jsp:useBean related doubt
Is this an error in HFSJ ??
Whats the error???
HFSJ Question Pg No 356