final String pageName = (String) webSocketData.getNodeData().get(Page.name.dbName());
final SecurityContext securityContext = getWebSocket().getSecurityContext();
try {
Page newPage = Page.createNewPage(securityContext, pageName);
if (newPage != null) {
Element html = newPage.createElement("html");
Element head = newPage.createElement("head");
Element body = newPage.createElement("body");
Element title = newPage.createElement("title");
Element h1 = newPage.createElement("h1");
Element div = newPage.createElement("div");
try {
// add HTML element to page
newPage.appendChild(html);
// add HEAD and BODY elements to HTML
html.appendChild(head);
html.appendChild(body);
// add TITLE element to HEAD
head.appendChild(title);
// add H1 element to BODY
body.appendChild(h1);
// add DIV element to BODY
body.appendChild(div);
// add text nodes
title.appendChild(newPage.createTextNode("${capitalize(page.name)}"));
h1.appendChild(newPage.createTextNode("${capitalize(page.name)}"));
div.appendChild(newPage.createTextNode("Initial body text"));
} catch (DOMException dex) {
dex.printStackTrace();