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 {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try{
String message = GatewayHook.PRResources.toString();
req.setAttribute("atribute1",message);
req.getRequestDispatcher("/WEB-INF/report.html").forward(req,resp);
}catch (Exception e){
}
}
}
3.- Creating an html in the module path “mymodule/src/main/WEB-INF/report.html”:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>This is a report!</title>
</head>
<body>
<p>Sample: ${attribute1}</p>
</body>
</html>
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 ?
The url would be ip:port/main/REPORTING.
Thanks!
EDIT: Do I need to use gatewayHook::moutRouteHandlers, adding a route with the html in it? Which datatype would it be?