0

I have made my application to run as root in tomcat using This post.

Now my application coming in browser as http://localhost:8080/ instead of http://localhost:8080/myApp/ As i Expected.

I have single menubar at the top which is same for every page using <%@include file="/jsp/header.jsp" %>

There is home button what will bring user to the home page from any level of url like http://localhost:8080/a http://localhost:8080/a/b/c all to http://localhost:8080/.

before making my app root i was using

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

But now ${pageContext.request.contextPath} value is and empty string() . so the generate html is

<a href="" class="...."></a>

Which is only reloading the current page when clicked.
What should i do to make it work like before. And i would like to make it server independent (now it is in local host some day it will go to a real serve i hope).

Community
  • 1
  • 1
Saif
  • 6,804
  • 8
  • 40
  • 61
  • if every body think this question is not worthy enough,then i can delete this as it has very easy solution which is give by @fd. – Saif Jan 26 '15 at 14:48

1 Answers1

2

You should be able to add a / character and have the URL work in both cases.

<a class="...." href="${pageContext.request.contextPath}/">Home</a>
Mike Tunnicliffe
  • 10,674
  • 3
  • 31
  • 46
  • well that worked .. i am thinking of my self a dumb and stupid because of not trying that. By the way thanks. – Saif Jan 26 '15 at 14:45