Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on HFSJ web deployment question

 
zhong chen
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 3918
10
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Hasnain Javed Khan
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
zhong chen
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic