In Eclipse, the folder structure when I create a Dynamic Web Project is
[srikanth@hana Sample]$ ls -R
.:
build src WebContent
./build:
classes
./build/classes:
./src:
./WebContent:
index.html META-INF scripts WEB-INF
./WebContent/META-INF:
MANIFEST.MF
./WebContent/scripts:
jquery-1.7.1.js
./WebContent/WEB-INF:
lib web.xml
./WebContent/WEB-INF/lib:
As you can see, there is this WebContent directory, When I copy the directory structure from Eclipse workspace and put in webapps directory of Tomcat, it didn't work. But, if I moved all the directories and files under WebContent directory a level above, it worked fine.
This is the folder structure in Tomcat's webapps directory under application:
[srikanth@hana Sample]$ ls -R
.:
build index.html META-INF scripts src WEB-INF
./build:
classes
./build/classes:
./META-INF:
MANIFEST.MF
./scripts:
jquery-1.7.1.js
./src:
./WEB-INF:
lib web.xml
./WEB-INF/lib:
So, now I can just go to http://localhost:8080/Sample
and can go to index.html properly
What am I doing wrong? Why didn't it work just copying the application from Eclipse to tomcat webapps directory directly? Why do I have to change the directory structure?
When I copy the directory structure from Eclipse workspace and put in webapps directory of Tomcat, it didn't work. But, if I moved all the directories and files under WebContent directory a level above, it worked fine
Not sure what you mean if I moved all the directories and files under WebContent directory a level above, it worked fine
here and what you mean by saying a level above
.
What you should be doing is not copy anything manually but right-click on the project and select Export as WAR
option.
This will create a file named Project.war
that contains the proper file structure i.e. WEB-INF
etc that you are supposed to put under tomcat's webapps
dir