2

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.

9
  • 2
    i suggest the first one. easy to understand and soon new employees can understand the structure by just one sight. Commented Nov 27, 2013 at 8:54
  • Consider putting your .jsp files underneath WEB-INF. It's generally considered safer, as it ensures that they cannot be loaded directly via a URL. Commented Nov 27, 2013 at 9:04
  • @Steve can you please draw the folder structure which should be very useful . Because I can have upto 10 - 15 JSP's for every module. Commented Nov 27, 2013 at 9:10
  • But why 3 modules not eg. 2 ? or 4 ? Commented Nov 27, 2013 at 9:11
  • @Mr-Phi any number of modules in future. But currently we have only 3 modules in our product. Commented Nov 27, 2013 at 9:17

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for your answer. Also why you put the conf in web-inf ?
I assumed that the conf files should not be visible to users of the web application. Maybe that's not the case?
Where are the .java files?
In a typical Maven War project structure, the above would be in src/main/webapp, whereas Java sources would be in src/main/java. In the final package, the Java sources would be compiled to .class files in WEB-INF/classes or (preferred) Jar files in WEB-INF/lib. Maven or Gradle will do that for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.