aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Question on HFSJ web deployment question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Question on HFSJ web deployment question" Watch "Question on HFSJ web deployment question" New topic
Author

Question on HFSJ web deployment question

zhong chen
Greenhorn

Joined: Oct 12, 2009
Posts: 24
In the questions after the chapter 11, the last question:

Which statements concerning the container class loader are true? (Choose all that apply.)
A. Web applications should NOT attempt to override container implementation classes.
B. A web application must not attempt to load resources from within the WAR file using the J2SE semantics of getResource.
C. A web application may override any J2EE classes in the javax.* namespace.
D. A web developer may override J2EE platform classes provided they are contained in a library JAR within a WAR.

I don't have a clue on what this question and the answers mean, and what does it mean to override a class? Isn't it true only methods in a class can be overridden? Can't we override doPost() of javax.servlet.HttpServlet?
Hasnain Javed Khan
Ranch Hand

Joined: Nov 23, 2007
Posts: 73
Hi,

The following is quoted from the Servlet Spec 2.4 Chapter SRV 9 Web Applications.


SRV.9.7.2 Web Application Class Loader
The class loader that a container uses to load a servlet in a WAR must allow the
developer to load any resources contained in library JARs within the WAR
following normal J2SE semantics using getResource
. As described in the J2EE
license agreement, servlet containers that are not part of a J2EE product should not
allow the application to override J2SE platform classes, such as those in the java.*
and javax.* namespaces, that J2SE does not allow to be modified. Also, servlet
containers that are part of a J2EE product should not allow the application to
override J2SE or J2EE platform classes, such as those in java.* and javax.*
namespaces, that either J2SE or J2EE do not allow to be modified. The container
should not allow applications to override or access the container’s implementation
classes
. It is recommended also that the application class loader be implemented so
that classes and resources packaged within the WAR are loaded in preference to
classes and resources residing in container-wide library JARs.


This is something I did not like about HFSJ. There are many such questions that HFSJ does not give any details about in the chapters and asks such questions at the end of the chapters .

Hope this helps.

Kind Regards.
Hasnain.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3838

Hasnain Javed Khan wrote:This is something I did not like about HFSJ. There are many such questions that HFSJ does not give any details about in the chapters and asks such questions at the end of the chapters..

That's why authors specifically mentioned to read the specs for more details


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Hasnain Javed Khan
Ranch Hand

Joined: Nov 23, 2007
Posts: 73
Vijitha Kumara wrote:
Hasnain Javed Khan wrote:This is something I did not like about HFSJ. There are many such questions that HFSJ does not give any details about in the chapters and asks such questions at the end of the chapters..

That's why authors specifically mentioned to read the specs for more details


Not necessarily


You should have a copy of the specs, although you do not need them in order to
pass the exam



Kind Regards.
Hasnain.

avi sinha
Ranch Hand

Joined: Mar 15, 2009
Posts: 453

whenever a class is requested the container at first looks in to the classes folder directly inside WEB-INF. if unable to find it start looking for it in other directories like lib inside WEB-INF.
it gives you a chance to override a class by creating yourself and putting it inside classes.

here in the question answer would be A.

avi sinha


SCJP 5.0 SCWCD 5.0
zhong chen
Greenhorn

Joined: Oct 12, 2009
Posts: 24
Thank you all for the explanation. I still don't get what "override" a class means. Could you shed some light on it?
avi sinha
Ranch Hand

Joined: Mar 15, 2009
Posts: 453

zhong chen wrote:Thank you all for the explanation. I still don't get what "override" a class means. Could you shed some light on it?


for example there is a class file avi.class inside a jar file avi.jar kept in the lib directory.
now you again create another class file avi.class and put it inside classes folder of WEB-INF.

now when the container will start looking for it , it will find the class in the classes folder even if you have intended to use the one inside the jar file

avi sinha
zhong chen
Greenhorn

Joined: Oct 12, 2009
Posts: 24
Thank you avi. But that doesn't make sense. Why would one want to create her own type say javax.servlet.HttpServletRequest? I wonder will it even compile. My understanding is you cannot create you own type in the java and javax namespace, right?
avi sinha
Ranch Hand

Joined: Mar 15, 2009
Posts: 453

zhong chen wrote:Thank you avi. But that doesn't make sense. Why would one want to create her own type say javax.servlet.HttpServletRequest? I wonder will it even compile. My understanding is you cannot create you own type in the java and javax namespace, right?


that's what the specification says

avi sinha
 
Don't get me started about those stupid light bulbs.
 
subject: Question on HFSJ web deployment question