Reputation: 126
A string is got from ENV variable by the following codes:
<span><%=(String)System.getenv("NEW_COPYRIGHT")%></span>
The ENV variable is like Copyright © {0} XXX
.
How to replace {0}
with the current year and display Copyright © 2018 XXX
in the jsp file?
Thanks
Upvotes: 2
Views: 1676
Reputation: 13506
There is no standard jstl
tag to do this.We can use other way to do it.
a. Use fn:replace
to do it:
<c:set var="env" value="Copyright © {0} XXX"/>
<c:out value="${fn:repalce(env,'{0}','2018')}"/> <!-- the year can also be access via a variable -->
b. Define your own custom tag to format it using java.text.MessageFormat
,more details can be found at Understanding and Creating Custom JSP Tags
Upvotes: 1