String formatStr = request.getParameter("format");
if (formatStr != null) {
if (!layer.supportsFormat(formatStr)) {
throw new GeoWebCacheException(
"Unknow or unsupported format " + formatStr);
}
} else {
formatStr = layer.getDefaultMimeType().getFormat();
}
if(request.getPathInfo().startsWith("/demo")) {
// Running in GeoServer
page = generateHTML(layer, gridSetStr, formatStr, true);
} else {
page = generateHTML(layer, gridSetStr, formatStr, false);
}
} else {
if(request.getRequestURI().endsWith("/")) {
try {
String reqUri = request.getRequestURI();
response.sendRedirect(response.encodeRedirectURL(reqUri.substring(0, reqUri.length() - 1)));
} catch (IOException e) {
e.printStackTrace();
}
return;
} else {
page = generateHTML(tileLayerDispatcher, gridSetBroker);
}
}
response.setContentType("text/html");
response.setCharacterEncoding("UTF-8");
try {
response.getOutputStream().write(page.getBytes());
} catch (IOException ioe) {
throw new GeoWebCacheException("failed to render HTML");
}
}