I’m trying to create a percentage bar with HTML+CSS.
I have the following code:
<div id="fundingBar">
<div id="fundingPercentage" style="width:45%"><p class="percentage">45%</p></div>
</div>
Now I want the percentage to be a dynamic value, so I have a session attribute called “percentage”. I’d like to use this value in the JSP page and the only way I know is using EL, so it should be something like this:
<div id="fundingBar">
<div id="fundingPercentage" style="width:${percentage}%"><p class="percentage">${percentage}%</p></div>
</div>
but this doesn’t work, so is there any way to do it this way or I should use javascript or something like that?
Thanks!
EL in template text (read: EL in plain HTML outside any JSP tags) works only if the
web.xmlis declared conform Servlet 2.4 or newer and if your webapp is deployed to a container which supports Servlet 2.4 or newer (which is already out since November 2003) and your webapp doesn’t contain servletcontainer-specific libraries of an older version in its/WEB-INF/libwhich would only collide container’s own libraries.Otherwise, if it’s indeed a legacy system and not just a misconfigured
web.xmlversion or a version clash in the classpath, then your only and ugly resort is using JSTL<c:out>.See also:
Of course I assume that you have really set the session attribute beforehand like so: