Hi all, The following question is mock exam in this site, i got wrong answers although i understanding the concept. can anyone tell me does same question appear real exam ? Qution: Which of the following statements are TRUE? (Choose Two) 1. Files in the WEB-INF directory can not be served to the client. 2. Files in the WEB-INF directory can be served to the client. 3. The servlet class files must reside as a sub-directory of WEB-INF named classes. 4. The web.xml deployment descriptor can reside outside the WEB-INF directory as long as it has been properly mapped. The provided answer is 1 & 3. I choose answer 2 & 4, because i think "can be served to.." means "can directly or indirectly", is that right ?(may be my english is poor), i choose 4 because i think the class can be put in a jar file when i do the mock exam. i don't want to face the same type of question in real exam !
A special directory exists within the application hierarchy named “WEB-INF”. This directory contains all things related to the application that aren’t in the document root of the application. The WEB-INF node is not part of the public document tree of the application. No file contained in the WEB-INF directory may be served directly to a client by the container. However, the contents of the WEB-INF directory are visible to servlet code using the getResource and getResourceAsStream method calls on the ServletContext. Hence, if the Application Developer needs access, from servlet code, to application specific configuration information that he does not wish to be exposed to the web client, he may place it under this directory. Since requests are matched to resource mappings case-sensitively, client requests for ‘/WEB-INF/foo’, ‘/WEb-iNf/foo’, for example, should not result in contents of the web application located under /WEB-INF being returned, nor any form of directory listing thereof. The contents of the WEB-INF directory are: • The /WEB-INF/web.xml deployment descriptor. • The /WEB-INF/classes/ directory for servlet and utility classes. The classes in this directory must be available to the application class loader. • The /WEB-INF/lib/*.jar area for Java ARchive files. These files contain servlets, beans, and other utility classes useful to the web application. The web application class loader must be able to load classes from any of these archive files.
Joined: Sep 01, 2002
hi Anthony, Thanks for you repily, I know that resource in /WEB-INF/ can't access by client directly, but i have a doubt here, because the resource in /WEB-INF/ can access by client indirectly through other jsp/servlet ! is that answer 2 only means directly serves ?
Joined: Mar 22, 2002
Originally posted by Jacky Chow: I know that resource in /WEB-INF/ can't access by client directly, but i have a doubt here, because the resource in /WEB-INF/ can access by client indirectly through other jsp/servlet ! is that answer 2 only means directly serves ?
Thank you for your points. The answers where modified to conatin the word "directly" and the answer for the servlet class files was reworded to say "can be located in..." If you find any others please bring them to my attention.
hi, I think in the question, the phrase: "served to clients" means, you can type that url in your web-browser: http://host/app/WEB-INF/**.whatever this is what "served to clients" means. It means directly accessible. I know it is confusing somehow. but I saw a couple of mock questions and the real one actually also use this phrase to mean directly accessble.