Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the document root of a JavaEE Application?

This is from the Java EE6 Tutorial:

A web module has a specific structure. The top-level directory of a web module is the document root of the application. The document root is where XHTML pages, client-side classes and archives, and static web resources, such as images, are stored.

The document root contains a subdirectory named WEB-INF, which can contain the following files and directories

But in here, it seems like the WEB-INF directory is not the document root. Also when you create a JSF Project using NetBeans, the folder structure will be like:

ProjectName
|
|
--src
|
|
--web
   |
   |
   --WEB-INF

which means the web directory again is not the document root?

So which is correct?

Because in Java EE6 Tutorial, the text continues:

The document root contains a subdirectory named WEB-INF, which can contain the following files and directories classes: A directory that contains server side classes: servlets, enterprise bean class files, utility classes, JavaBeanscomponents

But according to Netbeans, and the tutorial above, server side classes are in a different directory?

Help with this confusion please?

like image 831
Koray Tugay Avatar asked Nov 21 '25 12:11

Koray Tugay


1 Answers

The EE spec talks about the directory structure of your final war file. The directory structure you put in your question is how IDE arranges different files in its project structure. They are two different things.

To answer your question, the document root in the war is the parent directory of WEB-INF directory. Different IDE has different document root for the project structure, but in most cases, it is the parent directory of WEB-INF directory too. In the netbeans case, it is the web folder. In the standard Eclipse web project, it is the WebContent directory. In the maven world, it is the src/main/webapp directory. These are all configurable though in the IDE.

like image 66
Lan Avatar answered Nov 23 '25 01:11

Lan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!