Reputation:
I have some links in my JSP page and I want to make the selected link Bold. I have CSS as :
.selected { font-weight: bold; }
and my JSP Code is :
<li <c:choose>
<c:when test="${subject.subjectId == param.subj_id}">
<c:set var="s" value="class=\"selected\"" scope="request"/> <!-- Here I'm setting class=selected
<c:out value="${s}"/>
</c:when>
</c:choose>><a href='/super-context/view-controller?action=view-content&subj_id=
<c:out value="${subject.subjectId}"/>'>
<c:out value="${subject.subjectName}" />
</a></li>
But above code does not work and when I go to page-source I see the line below
<c:out value="${s}"/>
prints :
<li class="selected">
please tell how to get this in :
<li class="selected">
Upvotes: 0
Views: 548
Reputation: 46851
By default, escapeXml
is true, and the <c:out>
tag thus escapes the HTML If you don't want to escape, you could simply use
${s}
instead of
<c:out value="${s}"/>
There is no need of <c:out>
at all in your case. Do it in the same way for all the <c:out>
tag.
c:out
escapes HTML characters so that you can avoid cross-site scripting.
For more info have a look at below posts:
Upvotes: 2
Reputation: 262644
<c:out>
escapes special characters such as quotes.
If you don't want that, you can turn it off:
<c:out value="class=\"selected\"" escapeXml="false"/>
Upvotes: 1