A Web Servlet is a Component that can be added to a Station. Alternatives to creating a Web Servlet are Servlet View and standard Java Servlets.
Once a Web Servlet has been added to a Station and is operational…
To create a Web Servlet in Niagara AX, a developer has to…
A user adds the Servlet Component to a Station via a palette file.
This is a simple Web Servlet that can be accessed in a browser via https://localhost/myFirstServlet
…
@NiagaraType
@NiagaraProperty(
name = "servletName",
type = "baja:String",
flags = Flags.READONLY,
defaultValue = "myFirstServlet"
)
public final class BMyFirstWebServlet extends BWebServlet
{
/*+ ------------ BEGIN BAJA AUTO GENERATED CODE ------------ +*/
/*@ $com.tridium.web.servlets.BMyFirstWebServlet(522312782)1.0$ @*/
/* Generated Wed May 13 12:49:26 BST 2015 by Slot-o-Matic (c) Tridium, Inc. 2012 */
////////////////////////////////////////////////////////////////
// Property "servletName"
////////////////////////////////////////////////////////////////
/**
* Slot for the {@code servletName} property.
* @see #getServletName
* @see #setServletName
*/
public static final Property servletName = newProperty(Flags.READONLY, "myFirstServlet",null);
/**
* Get the {@code servletName} property.
* @see #servletName
*/
public String getServletName() { return getString(servletName); }
/**
* Set the {@code servletName} property.
* @see #servletName
*/
public void setServletName(String v) { setString(servletName,v,null); }
////////////////////////////////////////////////////////////////
// Type
////////////////////////////////////////////////////////////////
@Override
public Type getType() { return TYPE; }
public static final Type TYPE = Sys.loadType(BMyFirstWebServlet.class);
/*+ ------------ END BAJA AUTO GENERATED CODE -------------- +*/
@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>");
}
}
Copyright © 2000-2019 Tridium Inc. All rights reserved.