I am working on a preexisting web application built with JSP, which uses an external Java library. I want to make some JavaBeans that were instantiated with jsp:useBean tags available to the Java code.
What would be a good practice to do that? I suppose I can pass the objects in question to every function call that requires them, but I’d like to avoid that.
Application scoped objects are stored as attributes of the
ServletContext. If the “function call” has access to theServletContext, then it can just grab them as follows:I of course expect that the “function” is running in the servlet context. I.e. it is (in)directly executed by a servlet the usual way.