0
votes

One of our project we deployed in tomcat 5.5. our code is not an war file. deployed as a jar. and we did not deploy directly under webapps . we created new folder and placed everything over there. and we configured that path in server.xml under context tag

<code>
< Context path="/ABC" docBase="/app/apache-tomcat-5.5.26/webapps/ABC/"
                 debug="1" reloadable="true" crossContext="true">

  < /Context>
</code> 

The problem is. we were able to land on home page but the images are not load and none of the links are not working Home page link ; //ip:port/ABC/home.jsp

when we click any of the links then the context path is getting removed like the below one of the link : //ip:port/firstlink.jsp

please help me where we have to config the context path

Thanks in advance

1
How are you links generated? Are they relative? Or maybe absolute like <a href="/home.jsp">. Some sample code could help.Tobías
<ul id="quickLinksMenu" class="menu"> <li><a href="/home.jsp">Home</a></li> <li><a href="/search/advancedSearch.jsp">Search</a></li> <script language="javascript" src="/svg/charts.js"></script> <li><a href="#" onclick="hideCurrentMenu(); return openChart();">Charts</a>Karthick

1 Answers

0
votes

Your link <a href="/home.jsp"> is absolute to your domain, you need to include the context in the URL. To obtain the current context use request.getContextPath

getContextPath

String getContextPath()

Returns the portion of the request URI that indicates the context of the request. The context path always comes first in a request URI. The path starts with a "/" character but does not end with a "/" character. For servlets in the default (root) context, this method returns "".

...

Returns: a String specifying the portion of the request URI that indicates the context of the request

HttpServletRequest#getContextPath()

You can retrieve this value in JSP with ${pageContext.request.contextPath}. Your link should be:

<a href="${pageContext.request.contextPath}/home.jsp">Home</a>