[FEATURE] Using servlet in custom module

Dears,
I would like to try using a servlet inside a custom module.
I am able to add/remove the servlet in the gateway hook of the module, via:

gatewayContext.getWebResourceManager().addServlet({servlet}.PATH, {servlet}.class);

gatewayContext.getWebResourceManager().removeServlet({servlet}.PATH);

I am wondering if I would be able to access, from the servlet, a class object instantiated in the startup of the module gateway hook.

Thank you.
Best regards.

You’ll have to use a static method in your Gateway Hook class to access a static field containing the object of interest. Store the object of interest in the static field during setup or startup.

1 Like

Thank you, @pturmel. That’s the right approach.