Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

web application without WEB-INF  RSS feed

 
sam liya
Ranch Hand
Posts: 1271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to have a packaged Web Application without a WEB-INF directory?
then how ?
 
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
Well, you need a web.xml file, and the web.xml file needs to go in the WEB-INF folder.

I know on tomcat I can just throw a JSP page into a folder and tomcat will process it. So, essentially, that's a folder with a single JSP file in it. Is that a 'web application.' Well, if this was a job interview, and you told me that it passed mustard with your definition of a J2EE web app, well, you certainly wouldn't be working on my team. But, from an academic 'will it work' perspective, well, in Tomcat it will. Will it work in future versions, or in all JEE web containers? Well, that's another question.

I typically find that creating a WEB-INF folder and a web.xml file is fairly inexpensive. If you can afford the extra cost, I definitely suggest doing it.

-Cameron McKenzie
 
sam liya
Ranch Hand
Posts: 1271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the webapp folder of tomcat there is a folder name mywebapp.
in that folder there is a index.jsp,welcome.jsp and hellow.java servlet.
if i call welcome jsp in index.jsp no problem.
but if i call hellow.java servlet t gives error.why is that .
there is no web-inf folder in my webapp.
why we need web-inf.
I need more exlaing?
 
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
Does a web application need a JSP? If you have no files, and deploy an application that has no files in it, is it still a web application? If a tree falls in a forest with nobody to hear it, does it make a sound?

I think the hard, cold truth is that the Servlet and JSP API says that every J2EE compliant web application or war file needs a WEB-INF folder that contains a deployment descriptor named web.xml. That's part of the specification. Why? I'm not sure. Some Canadians who are much smarter, better looking and probably better mannered than me decided that was the way it was going to be, and I accept it.

Does every HTML page need to start with an <HTML> tag and end with an </HTML> tag? Well, the xHTML specification and HTML4.0 specification says it does. But, I can write a web page without start and end HTML tags and every internet browser will still display it properly. Should we start asking why a web page needs start and end HTML tags, or should we just recognize that the specification says that is the way it should be done, and also accept that when some people don't follow the rules properly, the web browsers just happen to be friendly and smart enough to compensate for programmers who are lazy and poorly trained?

Essentially, it's is so because the specification says it is so.

-Cameron McKenzie
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66205
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's WEB-INF, not web-inf. And yes, as pointed out, you need it.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!