This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
(The reason I am asking this question: Some years ago I built a web application hosted by Webappcabaret using basically this structure. The people at Webappcabaret tweaked something or other and got this to work. Now I have to move my application out of Webappcabaret into a new host. But when I get all the files into a .war file and put it in the webapps directory of the Tomcat7 on my local machine, the homepage no longer gets served as the first page. Also, Tomcat no longer recognizes the style sheet placed in the subdirectory. I am trying to get these issues resolved on my local machine before placing the web application in a new host.)
Firstly you have to understand the directory structure of a web application and how it gets deployed as war on tomcat. The important thing to understand is that the WebContent folder is the root of your project hierarchy and all references made to subfolders inside webcontent are to be referenced from root. So if you REAL_SIMPLE_TEST_HOME.jsp is located directly inside the WebContent folder, then you have to put the following entry in your web.xml
Similarly for your styles folder, refer it to as /styles/Stylesheet.css
Do post back for any further queries
Muhammad Saif Asif Mirza
OCJA(5/6) OCJP(6) OCJWCD(6)
Joined: Mar 03, 2013
Unfortunately, this does not work:
I get an Apache Tomcat Status 404 error.
I should mention that RealSimpleTest is under the webapps directory. Tomcat seems to interpret the '/' as meaning 'webapps/RealSimpleTest'. But I need the first page served to be uner webapps/RealSimpleTest/WebContent instead.
Try removing the forward slash from the path of the JSP . Its at the root of the project , so it should have worked . ( always works for me ) . Anyhow try to remove the "/" from the path and change it to "REAL_SIMPLE_TEST_HOME.jsp"
I suspect that you are depending on your IDE to deploy the web application. Depending on the IDE and plugins involved, it's most likely that "/WebContent" is actually something like the root of the WAR that the IDE assembles into. Thus, the true resource path within the webapp would be "/index.jsp".
An IDE is no substitute for an Intelligent Developer.