It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Velocity ServletContext

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.

1 answer

Hi,

Did you try to do

${links}

in your Velocity template?

Fred

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Next-gen

Keyboard shortcuts have arrived for next-gen projects!

...ollected feedback from users around the lack of shortcuts, and we’re here to address that: In next-gen projects, I miss the keyboard shortcuts badly. This is particularly true on the Board, but also i...

278 views 2 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you