I read in one book (David Bridgewater) saying that WEB-INF is not mandatory for a web app to work. Here is what the book has to say about it,
"Having a directory called WEB-INF is a strong recommendation, but not an absolute obligation. Look out for questions that ask you to say whether a web application must have particular directories. The correct answer is �no�! More usually, though, questions will be phrased to allow for this loophole in the specification. So if you see a question along these lines��Should a servlet class live in the WEB-INF/classes directory?��you are safe to answer �yes.� The expectation is that files normally do live in the recommended file structure." [ April 30, 2007: Message edited by: Jothi Shankar Kumar Sankararaj ]
My argument is that as per what the book says having a WEB-INF is not an obligation?? How can one attest this?? Anyone has tried of a similiar situation??
Joined: Sep 14, 1999
"My argument is that as per what the book says having a WEB-INF is not an obligation??"
If it's not necessary then it should be able to create an web application that acceses servlets without a WEB-INF directory. I have never seen this. If I can see and reproduce such a setup then I'll know that the WEB-INF is not necessary. Unless I see and test such a setup I'll believe that WEB-INF is necessary.
Of course, WEB-INF may be needed to run Servlets. But one can write JSPs with Scriptlets and Declaratives and call them from tomcat/webapps ( to mean that a registerd application can be run ) WITHOUT any WEB-INF directory. Well, JSP is a web component.
Joined: Nov 29, 2005
Originally posted by Sunder Ganapathy: Of course, WEB-INF may be needed to run Servlets. But one can write JSPs with Scriptlets and Declaratives and call them from tomcat/webapps ( to mean that a registerd application can be run ) WITHOUT any WEB-INF directory. Well, JSP is a web component.
If I can wind back this discussion a little, "Is the WEB-INF directory mandatory in a web application??"
I take the expression "web application" to mean the things I expect and are most common to find in a web application (the stuff that the SCWCD exam covers). Thus a meaningful web application might contain JSP, Servlets, Custom Tags, TagFiles and configuration informatin stored in the WEB.XML. If that is what a web application is then you must have a WEB-INF directory.
It is however possible to execute JSP files without a WEB-INF directory, but in my view a meaningful web application is more than JSP files. In short, for the purpose of the exam a web application will need a WEB-INF directory.
I am awaiting anyone giving me an example of executing servlets without the presence of WEB-INF, any takers?
If the DD is mandatory, then WEB-INF should be mandatory too. How would you put the web.xml file inside the WEB-INF directory (the only place the DD can be) if you haven't that directory inside your web application root path?
And while we are at it. What about META-INF inside a WAR file? Is it mandatory even if we don't need to specify dependencies?
And if META-INF is mandatory, do we need to put a MANIFEST.MF inside META-INF when we don't specify dependencies? Should it be an empty file?