title: May context path change on every request?
body: <p>I am developing a web application and something really strange happens. I run my JEE application on my local tomcat and all goes well. When I deploy my application online (on Heroku or Openshift, both), the context path changes on every request. For example, if I click on a link the app does everything correctly showing the content I expect, but from now on the context path (that I use in JSPs to generate links) changes to the current url. If I modify the url in the browser to the main page of the site it changes again. May be a configuration issue? I'm having an headache.
  I'm using urlrewrite to have pretty urls, so, if the home of my site is <a href="http://homesite/" rel="nofollow">http://homesite/</a> , an article is on <a href="http://homesite/article/year/month/article_slug" rel="nofollow">http://homesite/article/year/month/article_slug</a>. When, on the homepage, I click on a link to view an article and the page changes accordingly. After page changed, if I click on "Home" link in menu (generated with ${pageContext.request.contextPath}) it goes to to the same page I'm already.
  In every page of the site I added a javascript variable like this:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      context = "&lt;%=request.getContextPath()%&gt;";
  &lt;/script&gt;
  </code></pre>
  
  <p>and here contextpath is always empty, as it must be, I believe.
  This is the content of the JSP that generates the main menu of my site:</p>
  
  <pre><code>&lt;nav class="red accent-4"&gt;
      &lt;div id="uc-nav-menu-container" class="nav-wrapper"&gt;
          &lt;!--&lt;a href="#" class="brand-logo right"&gt;Unical Coin&lt;/a&gt;--&gt;
          &lt;a href="#" data-activates="mobile-demo" class="button-collapse left"&gt;&lt;i class="material-icons"&gt;menu&lt;/i&gt;&lt;/a&gt;
          &lt;ul id="nav-mobile" class="left hide-on-med-and-down"&gt;
              &lt;li class="active"&gt;&lt;a href="${pageContext.request.contextPath}"&gt;Home&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href="#"&gt;Mission&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href="#"&gt;Tecnologia&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href="#"&gt;About&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href="#"&gt;Links&lt;/a&gt;&lt;/li&gt;
          &lt;/ul&gt;
          &lt;ul class="red accent-4 side-nav" id="mobile-demo"&gt;
              &lt;li class="active"&gt;&lt;a href="${pageContext.request.contextPath}"&gt;Home&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a class="white-text" href="#"&gt;Mission&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a class="white-text" href="#"&gt;Tecnologia&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a class="white-text" href="#"&gt;About&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a class="white-text" href="#"&gt;Links&lt;/a&gt;&lt;/li&gt;
          &lt;/ul&gt;
          &lt;div id="uc-user-menu-container" class="right"&gt;&lt;/div&gt;
      &lt;/div&gt;
  &lt;/nav&gt;
  </code></pre>
  
  <p>And this is the JSP that generates an article page:</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
           pageEncoding="ISO-8859-1"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;jsp:include page="/WEB-INF/components/imports/default-head-imports.jsp"&gt;&lt;/jsp:include&gt;
      &lt;/head&gt;
      &lt;body class="blue-grey lighten-5"&gt;
          &lt;jsp:include page="/WEB-INF/components/nav-menu.jsp"&gt;&lt;/jsp:include&gt;
          &lt;div class="container"&gt;
              &lt;jsp:include page="/WEB-INF/components/single-article-content.jsp"&gt;&lt;/jsp:include&gt;
          &lt;/div&gt;
          &lt;jsp:include page="/WEB-INF/components/footer.jsp"&gt;&lt;/jsp:include&gt;
          &lt;jsp:include page="/WEB-INF/components/imports/default-foot-imports.jsp"&gt;&lt;/jsp:include&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The javascript variable in each page is generated only in "/WEB-INF/components/imports/default-head-imports.jsp" included.</p>