Source:
<code>protected void process(HttpServletRequest request, HttpServletResponse response) throws IOException { LOGGER.entering(); if (request.getSession(false) == null) { response.sendRedirect(LoginServlet.class.getSimpleName()); return; } PrintWriter writer = response.getWriter(); if (request.getParameter("form_id") != null && request.getParameter("form_id").equals("restart_nodes")) { boolean isForcedRestart = request.getParameter("submit").equals("Force Restart"); String nodes[] = request.getParameterValues("nodes"); if (nodes == null || nodes.length == 0) { ServletHelper.displayMessageOnRedirect(writer, "Please select at least 1 node in order to perform restart."); return; } for (String node : nodes) { RemoteProxy proxy = this.getRegistry().getProxyById(node); if (proxy == null) { continue; } if ((proxy instanceof SeLionRemoteProxy) && (((SeLionRemoteProxy) proxy).supportsForceShutdown())) { if (isForcedRestart) { LOGGER.info("Sending forced restart request to " + proxy.getId()); ((SeLionRemoteProxy) proxy).forceNodeShutdown(); } else { LOGGER.info("Sending restart request to " + proxy.getId()); ((SeLionRemoteProxy) proxy).requestNodeShutdown(); } } else { LOGGER.warning("Node " + node + " does not support restart."); } } ServletHelper.displayMessageOnRedirect(writer, "Restart process initiated on all nodes."); } else { List<ProxyInfo> proxies = getProxyInfo(); final String json = new GsonBuilder().serializeNulls().create().toJson(proxies); final String jsonUtf8 = new String(json.getBytes(), "UTF-8"); String template = IOUtils.toString(this.getClass().getResourceAsStream(RESOURCE_PAGE_FILE), "UTF-8"); <START> writer.write(String.format(template, jsonUtf8, GridForceRestartDelegateServlet.class.getSimpleName())); <END> } LOGGER.exiting(); }</code><technical_language>I create a ServletHelper#respondAsHtmlUsingJsonAndTemplateWithHttpStatus(HttpServletResponse resp, Object toJson, String resourcePageTemplate, int statusCode, String ... additionalStrings) in other places</technical_language>

Target:
protected void process(HttpServletRequest request, HttpServletResponse response) throws IOException { LOGGER.entering(); if (request.getSession(false) == null) { response.sendRedirect(LoginServlet.class.getSimpleName()); return; } if (request.getParameter(FORM_ID) != null && request.getParameter(FORM_ID).equals("restart_nodes")) { boolean isForcedRestart = request.getParameter(SUBMIT).equals("Force Restart"); String nodes[] = request.getParameterValues(NODES); if (nodes == null || nodes.length == 0) { ServletHelper.respondAsHtmlWithMessage(response, "Please select at least 1 node in order to perform restart."); return; } for (String node : nodes) { RemoteProxy proxy = this.getRegistry().getProxyById(node); if (proxy == null) { continue; } if ((proxy instanceof SeLionRemoteProxy) && (((SeLionRemoteProxy) proxy).supportsForceShutdown())) { if (isForcedRestart) { LOGGER.info("Sending forced restart request to " + proxy.getId()); ((SeLionRemoteProxy) proxy).forceNodeShutdown(); } else { LOGGER.info("Sending restart request to " + proxy.getId()); ((SeLionRemoteProxy) proxy).requestNodeShutdown(); } } else { LOGGER.warning("Node " + node + " does not support restart."); } } ServletHelper.respondAsHtmlWithMessage(response, "Restart process initiated on all nodes."); } else { List<ProxyInfo> proxies = getProxyInfo(); ServletHelper.respondAsHtmlUsingJsonAndTemplateWithHttpStatus(response, proxies, RESOURCE_PAGE_FILE, HttpServletResponse.SC_OK); } LOGGER.exiting(); }