What is WEB-INF used for in a Java EE web application?

I’m working on a Java EE web application with the following source code directory structure:

src/main/java                 <-- multiple packages containing Java classes
src/test/java                 <-- multiple packages containing JUnit tests
src/main/resources            <-- includes properties files for textual messages
src/main/webapp/resources     <-- includes CSS, images and all Javascript files
src/main/webapp/WEB-INF
src/main/webapp/WEB-INF/tags
src/main/webapp/WEB-INF/views

The folder I’m interested in is WEB-INF: It contains web.xml, XML files for setting up servlets, Spring bean wiring contexts and JSP tags and views. I’m trying to understand what constrains/defines this structure. E.g. do JSP files always have to be within WEB-INF or could they be somewhere else? And is there anything else that might go in WEB-INF? Wikipedia’s WAR files entry mentions classes for Java classes and lib for JAR files – not sure I’ve fully grasped when these would be needed in addition to the other source file locations.

5 Answers
5

Leave a Comment