GeeCON Prague 2014*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes WEB-INF mandatory?? 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 "WEB-INF mandatory??" Watch "WEB-INF mandatory??" New topic
Author

WEB-INF mandatory??

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9398
    
    2

Is the WEB-INF directory mandatory in a web application?? Will the exam test us on things like this??


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
saqib sarwar
Ranch Hand

Joined: Mar 30, 2007
Posts: 77
yes, it is definately mandatory for a j2ee web application.

and exam will contain questions about DD elements.


SCJP5 95%, SCWCD 85%<br />Knowledge is the Life of Mind
anil bs setty
Greenhorn

Joined: Apr 25, 2007
Posts: 8
yea WEB-INF is mandatory....for a web project...

In the exams there may be questions regarding where different types of files(like class files, libs etc.) will be placed inside the web-inf directory.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9398
    
    2

Guys,

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 ]
Marcus Green
arch rival
Rancher

Joined: Sep 14, 1999
Posts: 2813
Could anyone give an example where a web application loads a servlet that is not in the WEB-INF\classes directory or below?. If anyone can provide this I will try to reproduce it on my own computer.


SCWCD: Online Course, 50,000+ words and 200+ questions
http://www.examulator.com/moodle/course/view.php?id=5&topic=all
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Originally posted by Jothi Shankar Kumar Sankararaj:
Is the WEB-INF directory mandatory in a web application?? Will the exam test us on things like this??


Most importantly , in a web application where will you put your web.xml.

You have to memorize quite a lot of web.xml tags , you will get questions from web.xml tags.


Rahul Bhattacharjee
LinkedIn - Blog
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9398
    
    2

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??
Marcus Green
arch rival
Rancher

Joined: Sep 14, 1999
Posts: 2813
"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.
Sunder Ganapathy
Ranch Hand

Joined: Apr 01, 2003
Posts: 120
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.
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
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.


Answer specific to Tomcat.

Check out the web.xml in conf folder of tomcat.That is the web.xml in use and you override the properties by defining another web.xml in WEB-INF folder.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42042
    
  64
But one can write JSPs with Scriptlets and Declaratives and call them from tomcat/webapps.


My impression was that Tomcat uses the presence of a WEB-INF directory as an indicator that a directory actually is a web app, and will not serve content (including JSPs) from it otherwise.


Ping & DNS - my free Android networking tools app
Sunder Ganapathy
Ranch Hand

Joined: Apr 01, 2003
Posts: 120
We started the discussion whether WEB-INF directory is needed. Well, it is not needed always. David Bridgewater is right.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9398
    
    2

Sunder,

Can you show us a practical case??
Marcus Green
arch rival
Rancher

Joined: Sep 14, 1999
Posts: 2813
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?
Sergio Tridente
Ranch Hand

Joined: Mar 22, 2007
Posts: 329

Isn't the DD (web.xml) mandatory?

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?


SCJP 1.4 (88%) - SCJP 5.0 Upgrade (93%) - SCWCD 1.4 (97%) - SCBCD 5.0 (98%)
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9398
    
    2

Sergio,

Then what would you say for my post??
 
GeeCON Prague 2014
 
subject: WEB-INF mandatory??