File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Doubt about WEB-INF 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 "Doubt about WEB-INF" Watch "Doubt about WEB-INF" New topic
Author

Doubt about WEB-INF

anil kumar
Ranch Hand

Joined: Feb 23, 2007
Posts: 447
Hi

This is the statement from David Bridge water
------------------------------------------------------------------------
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�!
---------------------------------------------------------------------------

Is this statement right?

I think even if we have only static pages or some jsp pages which are not having any connection with java files,we must have WEB-INF folder.

Am i right?

Thanks

Anil Kumar
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

Yes, you're right, otherwise where to store the web.xml?


SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Am i right?

The specification does not say that WEB-INF is mandatory. It only says that there is special directory called WEB-INF
I think that it would be ok, but really crappy, to have such a web application. Containers like Tomcat will use their default web.xml (conf/web.xml).


[My Blog]
All roads lead to JavaRanch
anil kumar
Ranch Hand

Joined: Feb 23, 2007
Posts: 447
Hi

Freddy Wong

No,don't consider about web.xml file ,now.

See here what i want to ask is, can we put some static pages in the webserver with out WEB-INF.

I tried this in Tomcat 5.0 like this

First
|
|
|
------index.jsp


I checked with this URL

http://localhost:8080/First

i am getting this error


HTTP Status 404 - /First

--------------------------------------------------------------------------------

type Status report

message /First

description The requested resource (/First) is not available.


--------------------------------------------------------------------------------

Apache Tomcat/5.0.25



And now i added WEB-INF like this

First
|
|
|-----WEB-INF
|
|------index.jsp



And with the same url,i am getting some output


And one more thing i did not put any thing in the WEB-INF.Can any one please check this in application server.I don't know how to deploy manually in application server.I checked in netbeans with weblogic by deleting the WEB-INF folder,but when i started running the project,netbeans is creating those folders again.


Thanks

Anil Kumar
anil kumar
Ranch Hand

Joined: Feb 23, 2007
Posts: 447
Hi

Christophe Verre


I want to create a site which contains say some 10 html pages.In this case what is the use of WEB-INF? And if it is not mandatory ,how can i deploy?

Please See the previous post,if i try to do what happens.


Thanks

Anil Kumar
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
I still wonder, Bridgewater says it a convention followed by most of the web
container but there is no strong obligation to abide to that. But we should
abide to that. I was sure about WEB-INF directory that must exist.



Thanks,


cmbhatt
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42950
    
  70
In order to be recognized as a Java web application, there must be a WEB-INF directory. Some containers, e.g. Tomcat, won't serve anything unless that directory is present. Other servers might work diferently.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Some containers, e.g. Tomcat, won't serve anything unless that directory is present.

Tomcat works fine without a WEB-INF directory. At least Tomcat 5.5.X.
anil kumar
Ranch Hand

Joined: Feb 23, 2007
Posts: 447
Hi

I checked with jakarta-tomcat-5.5.3.It is not working.


Thanks

Anil Kumar
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

I tried with Tomcat 5.5.23. I have hello.html, containing a link to hello.jsp in my "dummy" application. I can access it via "http://localhost:8080/dummy/hello.html". There's no WEB-INF in there
anil kumar
Ranch Hand

Joined: Feb 23, 2007
Posts: 447
Hi

Thanks for clarifying Christophe Verre

Thanks

Anil Kumar
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42950
    
  70
Originally posted by Christophe Verre:
I tried with Tomcat 5.5.23. I have hello.html, containing a link to hello.jsp in my "dummy" application. I can access it via "http://localhost:8080/dummy/hello.html". There's no WEB-INF in there


Interesting. That used to be different in Tomcat 4. Well, it's been a few years :-)

But do JSP files work without a WEB-INF directory?
Marcus Green
arch rival
Rancher

Joined: Sep 14, 1999
Posts: 2813
It depends on what you consider a web application to be. If you want a setup that will contain any of the components of a web application, i.e. servlets, beans and JSP you must have a WEB-INF and a WEB.XML deployment descriptor. If you just want to display JSP pages you don't need either of those. But in my view a web application is more than just JSP pages.


SCWCD: Online Course, 50,000+ words and 200+ questions
http://www.examulator.com/moodle/course/view.php?id=5&topic=all
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

But do JSP files work without a WEB-INF directory?

Yes they do. My html file has only one anchor pointing to a JSP file. Both displayed correctly.
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3355

As chandra said, i was also very much damn sure about WEB-INF directory.

But i am aware that you can directly navigate to the static files (even jsp files) in Tomcat like servers, which can very well serve you.

But if you want the pages to be loaded within or inside the application, you should definitely have one WEB-INF directory. Am i correct?


Originally posted by Christophe Verre :
The specification does not say that WEB-INF is mandatory. It only says that there is special directory called WEB-INF


But still, it is a directory right? Or the special directory is something else? Can you please shed some lights on it.


Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

But still, it is a directory right? Or the special directory is something else?

Yes it's a special directory that the container will hide from the client. Web applications should have a WEB-INF. I don't know why the spec does not make it mandatory. A web application without a WEB-INF smells pretty bad, doesn't it ?
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

I couldn't imagine a war file/web application without a WEB-INF folder, or a web.xml file for that matter.

Will it deploy without one? Probably. Tomcat and other web servers are VERY forgiving. I love it when servers move from one version to the next, and the next version becomes more strict about enforcing the spec, and everyone cries "hey, my code doesn't work anymore!!!" I saw alot of the with JSP tags, where earlier containers let everything fly, and newer ones were much more strict.

If a developer of mine gave me a war file without a web.xml file in a WEB-INF folder, I'd look for a new developer. If it's not required, it is certainly a bad, bad, bad, bad practice. I know these exams test you on obscure stuff, but I can't for a minute believe that an absolute horrendously bad practice that would get most developers fired would ever be a correct answer on a certification exam.

Just my two cents.

-Cameron McKenzie
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
It may look awkward to see this question here after a lot discussion on the
factor that WEB-INF is mandatory or not.

This question is from the Quiz 3, Marcus Green:




b and e are correct answers.


Thanks,
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3355

I also feel that its contradicting Chandra!
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 918

Hi Chandra

the answer depends on what you consider to be a web-application. I you have something very small you can still place it in the document root directory, in this case the WEB-INF directory is mandatory. But this case of "small" application make no sense in the real word except they have didactically purposes, so the WEB-INF directory is mandatory but in most of the cases is recommended (to use it).


Regards,
M


SCJP, SCJD, SCWCD, OCPJBCD
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3355

Originally posted by Cameron McKenzie:

Will it deploy without one? Probably. Tomcat and other web servers are VERY forgiving. I love it when servers move from one version to the next, and the next version becomes more strict about enforcing the spec, and everyone cries "hey, my code doesn't work anymore!!!" I saw alot of the with JSP tags, where earlier containers let everything fly, and newer ones were much more strict.



Very true! Why there is no such strict enforcing on the same then?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt about WEB-INF