Human Being
Human Being

Reputation: 8387

Structure of Java web application?

Sorry to ask this simple question.I have searched a lot and I can't find a reliable answer that exactly what I want. That's why I created this question.

we completed two spring projects in Java.

Each project , we have created , has a different folder structure in WebContent for module separation.

Now we are going to start a new project using eclipse with SVN and the project has three modules.

WebContent Folder structure for Project one is ,

WebContent

    - moduleOne
        - conf
            - moduleOne.conf
        - css
            - moduleOne.css
        - js
            - moduleOne.js
        - jsp
            - moduleOne.jsp
        - images
            - moduleOne.png

    - moduleTwo
        - conf
            - moduleTwo.conf
        - css
            - moduleTwo.css
        - js
            - moduleTwo.js
        - jsp
            - moduleTwo.jsp
        - images
            - moduleTwo.png

    - META-INF

    - WEB-INF
        - lib
        - web.xml

WebContent Folder structure for Project one is ,

WebContent

    - conf
        - moduleOne
            - moduleOne.conf
        - moduleTwo
            - moduleTwo.conf

    - css
        - moduleOne
            - moduleOne.css
        - moduleTwo
            - moduleTwo.css

    - images        
        - moduleOne
            - moduleOne.png
        - moduleTwo
            - moduleTwo.png

    - js
        - moduleOne
            - moduleOne.js
        - moduleTwo
            - moduleTwo.js

    - jsp       
        - moduleOne
            - moduleOne.jsp
        - moduleTwo
            - moduleTwo.jsp



    - META-INF

    - WEB-INF
        - lib
        - web.xml

Now we are in a situation to choose the preferred way of creating a folder structure.

Also it should be:

  1. Easily customizable.

  2. Easy to modify a separate module,if any new requirement came.

Any new ideas or methods and all answers would also be greatly appreciated.

Upvotes: 2

Views: 9788

Answers (1)

Steve
Steve

Reputation: 9480

I like to keep static web resources under a 'resources' directory and all views and config underneath WEB-INF. This ensures that I can enable liberal access permissions and caching on 'resources'. Also, this ensures that .jsp files will not be directly accessible via a URL (unless you mess up your config!). Other than that, your first solution above is solid. Especially, as it becomes easier to apply module-level security and other configuration based on the path to the relevant module.

So as a tweak to solution 1, I would recommend something like:

- resources
    - moduleOne
        - css
            - moduleOne.css
        - js
            - moduleOne.js
        - images
            - moduleOne.png
    - moduleTwo
        - css
            - moduleTwo.css
        - js
            - moduleTwo.js
        - images
            - moduleTwo.png
- META-INF
- WEB-INF
    - modules
        - moduleOne
            - conf
                - moduleOne.conf
            - views
                - moduleOneViewOne.jsp
        - moduleTwo
            - conf
                - moduleTwo.conf
            - views
                - moduleTwoViewOne.jsp
    - lib
    - web.xml

Upvotes: 1

Related Questions