-1

window.location.href=location.origin+"/apreizspring/teammember"

apreizspring is my project name. I want to replace this by using pagecontext. Can anyone provide me a solution?

Henk van Boeijen
  • 7,357
  • 6
  • 32
  • 42

1 Answers1

3

In Javascript file:

window.location.href = requestContextPath + "/teammember"

Lets say, your javascript file is named temp.js

In jsp :

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<script>
    var requestContextPath = '${pageContext.request.contextPath}';
</script>
<script type='text/javascript' src = 'temp.js'></script>
Sachin
  • 901
  • 2
  • 10
  • 23