I have a class that defines the names of various constants, e.g.
class Constants {
public static final String ATTR_CURRENT_USER = "current.user";
}
I would like to use these constants within a JSP without using Scriptlet code such as:
<%@ page import="com.example.Constants" %>
<%= Constants.ATTR_CURRENT_USER %>
There appears to be a tag in the Apache unstandard taglib that provides this functionality. However, I cannot find any way to download this taglib. I'm beginning to wonder if it's been deprecated and the functionality has been moved to another (Apache) tag library?
Does anyone know where I can get this library, or if it's not available, if there's some other way I can access constants in a JSP without using scriptlet code?
Cheers, Don
On application startup, you can add the Constants class to the servletContext and then access it in any jsp page
servletContext.setAttribute("Constants", com.example.Constants);
and then access it in a jsp page
<c:out value="${Constants.ATTR_CURRENT_USER}"/>
(you might have to create getters for each constant)