#Calling setAttribute in attributeReplaced listener

4 messages · Page 1 of 1 (latest)

mental moss
#

If I call the setAttribute method of the ServletContext object in the attributeReplaced function of a ServletContextAttributeListener, would it lead the application to an infinite loop?

nova flameBOT
#

This post has been reserved for your question.

Hey @mental moss! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

mental moss
#
public void attributeReplaced(ServletContextAttributeEvent event) {
        if (event.getName().equals("config")) {
            ServletContext context = event.getServletContext();
            String configFilePath = context.getInitParameter("configFilePath");
            Config config = loadConfigFromFile(configFilePath);
            context.setAttribute("config", config);
        }
    }

like this