Seems like something is wrong with your deploying process, and for some reason Tomcat is trying to serve your application at the root of the server, because of that your ${pageContext.request.contextPath}
is returning empty.
Since I'm not sure of your exactly deployment requirements, try one of the following procedures. Just to be sure and avoid configuration conflicts, do it on a brand new Tomcat 7 installation:
- If you have a
MyApplication.war
file just drop it at<CATALINA_HOME>\webapps
, do not use any context files (be ware of context files inside the war file, i.e.,/META-INF/context.xml
) - If you have an exploded application, create a folder
MyApplication
insidewebapps
and drop the application contents there (again, nocontext.xml
).
If you really need to keep your application outside of webapps
:
Add a new
Context
element to<CATALINA_HOME>\conf\server.xml
inside<Host>
:<Context path="/MyApplication" docBase="/absolute/physical/path/to/MyApplication" reloadable="true" crossContext="true">
- Alternatively create a
MyApplication.xml
file in<CATALINA_HOME>\Catalina\localhost
with the content mentioned above.
For further info refer to The Context Container documentation.