Issue
I have recently installed Eclipse and Tomcat for developing Some Web Projects using JSP.
When I see some tutorials then their project structure was different but now it is completely changed. so I am confused that where to write Java Code and where to write JSP Code and HTML Code ?
OLD Project Structure
NEW
Solution
Most of tutorials are outdated and used older version of Eclipse.
Basically, in a java web application the final output either war or a folder should be as follows.
/ (Web resources like html, jsp, js and css files)
|
+--WEB-INF/
| |
| +--web.xml (optional since servlet 3.0)
| +--classes/ (will have the compiled java classes and class path resources)
| +--lib/ (third party libraries)
+--META-INF/ (will have manifest file)
Eclipse changed the folder structure to be on par with other build tools like Maven and Gradle.
In the new structure
src/main/java
will consists of java sources and other class-path resources like XMLs and other configuration files.src/main/webapp
will have all web resources.
When you build the app eclipse compiles the java classes from src/main/java
folder and put the class files in the WEB-INF/classes
also copies non java class-path resources as it is to WEB-INF/classes
. And the files in src/main/webapp
will be copied to the root(/
) folder as it is.
Off-Topic: I will advise you to use a build tool like Maven or Gradle so your project will work in any IDE and environment.
Answered By - Karthikeyan Vaithilingam