Hi,
How I can access attributes from Velocity template stored in Servlet Context
I have listerer
public class StartListener implements ServletContextListener { private static final Logger log = LoggerFactory.getLogger(StartListener.class); @Override public void contextInitialized(ServletContextEvent sce) { log.info("App starts"); ServletContext servletContext = sce.getServletContext(); servletContext.setAttribute("links", new Links()); } @Override public void contextDestroyed(ServletContextEvent sce) { log.info("App ends"); } }
In servlet I can do
Links links = (Links) getServletContext().getAttribute("links");
But I want to accses "links" directly from velocity template.
Hi,
Did you try to do
${links}
in your Velocity template?
Fred
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.