I am prepraring for SCWCD. I was going through HFSJ book yesterday and i could not follow these two points
1) HFSJ book says <load-on-startup> value can contain any non-negative number, and container loads in the order of the number given. In the same page, it is given that it should have a value of greater than zero. With this, I have a doubt whether we can have a <load-on-startup> value as zero, and will it be loaded before with value one? All negavtive numbers will be ignored by container?
2) In HFSJ book, regarding <servlet-mapping> there is no clear information is given.. Servlet mapping will be choosed based upon, exact match, directory match or extension match in the order. there were three mappings defined in web.xml servlet one - *.do servlet two - /fooStuff/bar servlet three - /fooStuff/*
I though aswer is two... but answer is given as three... There is no explanation is given in the book clearly why answer is three.. Can any one explain in detail, how servlet container matches servlet name based on url mapping? Or can any one refer to good material on this servlet mapping alone?
The load-on-startup element indicates that this servlet should be loaded (instantiated and have its init() called) on the startup of the web application. The optional contents of these element must be an integer indicating the order in which the servlet should be loaded. If the value is a negative integer, or the element is not present, the container is free to load the servlet whenever it chooses. If the value is a positive integer or 0, the container must load and initialize the servlet as the application is deployed. The container must guarantee that servlets marked with lower integers are loaded before servlets marked with higher integers. The container may choose the order of loading of servlets with the same load-on-start-up value.
2) <blockquote>quote: In HFSJ book, regarding <servlet-mapping> there is no clear information is given.. Servlet mapping will be choosed based upon, exact match, directory match or extension match in the order. there were three mappings defined in web.xml servlet one - *.do servlet two - /fooStuff/bar servlet three - /fooStuff/*
given this there is no exact match for 'fooStuff/bar/blue.do' there is a directory match which is not '/fooStuff/bar'. Because '/fooStuff/bar' does not end with an /* it is only compared to an exact match so the closest directory match is '/fooStuff/*' which is servlet three. I think that HFSJ does explain this somewhere, I would be really suprised if it didn't, but it may be later in the book, or in a side bar or bubble somewhere not entirly obvious. So reread the chapter and have a bit of a look for it. It is explained somewhere I am sure.
posted 14 years ago
Thanks a lot Mat for your explanation. It helped to understand better.
SCJA, SCJP, SCWCD, SCBCD, SCDJWS.
Well THAT's new! Comfort me, reliable tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop