Mdhar9e
Mdhar9e

Reputation: 1376

Getting error while setting context path to url

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.

Upvotes: 0

Views: 1564

Answers (1)

nfechner
nfechner

Reputation: 17535

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"; %>

Upvotes: 3

Related Questions