Question

I am setting the context path in jsp page but it is showing error while running the jsp page.

as shown below.

<c:set var="path" value="${pageContext.request.contextPath}"/>

<% urlName='<c:out value="${path}"/>/tran/handleTransactionResults.do'; %>

${path} is not showing the context path.

Was it helpful?

Solution

You cannot use JSP tags within a scriptlet. Do it like this:

<c:set var="path" value="${pageContext.request.contextPath}"/>
<% urlName= request.getAttribute("path") + "/tran/handleTransactionResults.do"; %>

Or even easier:

<% urlName= request.getContextPath() + "/tran/handleTransactionResults.do"; %>

If you simply want to output your path, you can use the <%= %> shortcut:

<%= request.getContextPath() + "/tran/handleTransactionResults.do"; %>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top