0

I have a variable named helpLocation in my js page.

like var helpLocation = 'http://localhost:9080/App/webhelp/Home.htm';

Here App is the Applciation Context.But it is hardcoded there. How can i set dynamically . I am trying to put as <c:set var="path" value="${pageContext.request.contextPath}"/> and var helpLocation = 'http://localhost:9080'+contextPath+'/webhelp/Home.htm'; . Then checked this with an alert as alert(helpLocation); but it is giving an alert with undefined

3
  • Use var contextPath = "<%=request.getContextPath()%>"; for setting context path. Commented Nov 8, 2011 at 6:17
  • Why aren't you using your var path for building you helpLocation? Commented Nov 8, 2011 at 6:29
  • like var helpLocation = 'localhost:9080/'+${path}+'/webhelp/Home.htm'; Commented Nov 8, 2011 at 6:30

1 Answer 1

1

Use

var contextPath = "<%=request.getContextPath()%>"; 

for setting context path in a jsp page.And contextPath should be a global javascript variable.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.