This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt about WEB-INF

 
anil kumar
Ranch Hand
Posts: 447
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you're right, otherwise where to store the web.xml?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
anil kumar
Ranch Hand
Posts: 447
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 447
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 447
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

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


Thanks

Anil Kumar
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 447
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Thanks for clarifying Christophe Verre

Thanks

Anil Kumar
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also feel that its contradicting Chandra!
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic