title: Java web app recommended project structure
body: <p>I'm using IntelliJ to create one of my first web apps. I'd like to use Gradle to solve my dependencies. Depending on how I create the project, it is structured differently.</p>
  
  <p>I was wondering whether there is a recommended project structure for web apps. Where to put the static pages? Where to put the classes? Where the other resources (like images)? And where to put other framework-specific files, like the build.gradle file?</p>
  
  <p>Right now I see three alternatives:</p>
  
  <p>If I create the project as a Java web application (File -> New Project -> check Java::JavaEE::Web Application -> Next etc...) I get the following project structure:</p>
  
  <pre><code>|-- WebApp.iml
  |-- src
  `-- web
      |-- WEB-INF
      |   `-- web.xml
      `-- index.jsp
  </code></pre>
  
  <p>If I create a Gradle project (File -> New Project -> check Gradle::Java and Gradle::Web -> Next etc...) I get the following structure:</p>
  
  <pre><code>|-- build
  |   `-- tmp
  |       `-- war
  |           `-- MANIFEST.MF
  |-- build.gradle
  |-- GradleWebApp.iml
  |-- out
  |-- settings.gradle
  `-- src
      `-- main
          `-- webapp
              `-- index.jsp
  </code></pre>
  
  <p>Before using IntelliJ I manually deployed a basic application to my local tomcat. The project structure was the following:</p>
  
  <pre><code>|-- WEB-INF
  |   |-- classes
  |   |   `-- servletsPkg
  |   |       `-- AServlet.class
  |   |-- src
  |   |   `-- servletsPkg
  |   |       `-- AServlet.java
  |   `-- web.xml
  |-- images
  |   `-- an_image.jpg
  |-- index.html
  `-- styles.css
  </code></pre>