A Servlet View is Niagara view that typically generates HTML.
Alternatives to extending BWebServlet are…
Please note…
A developer creates a Servlet View in the following way…
javax.baja.sys.BServletView.doGet or any other HTTP verb related methods to handle implementation.A few things to note about BServletView…
BServletView extends BSingleton. Therefore, there’s only ever one instance of a View.BHxView extends BServletView.Here’s an example of a Servlet View that will be rendered in a web browser when the user navigates to the UserService. Please note, in this case the view is declared as an Agent on baja:UserService.
public final class BMyFirstServletView extends BServletView
{
private BMyFirstServletView() {}
public static final BMyFirstServletView INSTANCE = new BMyFirstServletView();
@Override
public Type getType() { return TYPE; }
public static final Type TYPE = Sys.loadType(BMyFirstServletView.class);
@Override
public void doGet(WebOp op) throws Exception
{
op.getHtmlWriter()
.w("<!DOCTYPE html>").nl()
.w("<html>").nl()
.w("<head></head>").nl()
.w("<body>").nl()
.w("<h1>Hello World!</h1>").nl()
.w("</body></html>");
}
}