Using servlets in module development

Hello all!

There are a couple of posts on the forums regarding servlets but none seem to answer this problem:

I am trying to load a html into a servlet following these steps:

1.- Adding the servlet into the gateway in GatewayHook::setup :

getGatewayContext().getWebResourceManager().addServlet("/REPORTING", ReportHTMLServlet.class);

2.- Creating the ReportHTMLServlet class:

public class ReportHTTPServlet extends HttpServlet {

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
             String message = GatewayHook.PRResources.toString();
        }catch (Exception e){


3.- Creating an html in the module path “mymodule/src/main/WEB-INF/report.html”:

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <title>This is a report!</title>
    <p>Sample: ${attribute1}</p>

What am I missing? Do I need to add de @addServlet annotation into the servlet class? Is the html path wrong? Do I need a gateway restart? Maybe wrong aproach :slight_smile: ?

The url would be ip:port/main/REPORTING.


EDIT: Do I need to use gatewayHook::moutRouteHandlers, adding a route with the html in it? Which datatype would it be?