Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse Dynamic Web Project how to organize files?

So I'm learning web application development and I'm a bit confused about how to organize my files in the template provided by eclipse for Dynamic Web Application.

Should I place my HTML pages in WebContent? Where do I put the JSP and servlet source files? What convention is globally followed?

This is the structure of the template provided by eclipse

  • Deployment Descriptor
  • JavaScript Resources
    • WebContent
    • ECMAScript Built-In Library
    • ECMA 3 Browser Support Library
  • src
  • JRE System Library
  • Apache Tomcat v8
  • Web App Libraries
  • EAR libraries
  • build
  • WebContent
    • META-INF
    • WEB-INF
      • lib
like image 884
Programmerboi Avatar asked Feb 26 '15 12:02

Programmerboi


1 Answers

Place HTML and JSP pages in the WebContent directory.

The Eclipse help page referenced by android-weblineindia states that WebContent is:

The mandatory location of all Web resources, including HTML, JSP, graphic files, and so on. If the files are not placed in this directory (or in a subdirectory structure under this directory), the files will not be available when the application is executed on a server. The Web content folder represents the contents of the WAR file that will be deployed to the server. Any files not under the Web content folder are considered development-time resources (for example, .java files, .sql files, and .mif files), and are not deployed when the project is unit tested or published.

so CSS files and JS files needed by the browser should also be placed here.

Place java source files (so including servlet sources) in the src directory. The same help page states this for the source directory (although it suggests it is called JavaSource which looks like an error in the documentation):

Contains the project's Java source code for classes, beans, and servlets. When these resources are added to a Web project, they are automatically compiled and the generated files are added to the WEB-INF/classes directory. The contents of the source directory are not packaged in WAR files unless an option is specified when a WAR file is created.

If you look at project Properties -> Deployment Assembly you should see that files compiled from src are deployed to WEB-INF/classes and files in WebContent are deployed to the root of the WAR file

like image 132
Pete Avatar answered Nov 02 '22 06:11

Pete