/** * Convert the object to a string via {@link Object#toString()} and HTML * escape the resulting string for use in HTML content. * * @param obj The object to convert to String and then escape * * @return The escaped content or <code>"?"</code> if obj is * {@code null} */ public static String htmlElementContent(Object obj) { if (obj == null) { return "?"; } try { return htmlElementContent(obj.toString()); } catch (Exception e) { return null; } }
protected String encode(String value, String encoding) { String retVal = null; if (encoding.equalsIgnoreCase("url")) { retVal = URLEncoder.DEFAULT.encode(value, StandardCharsets.UTF_8); } else if (encoding.equalsIgnoreCase("none")) { retVal = value; } else if (encoding.equalsIgnoreCase("entity")) { retVal = Escape.htmlElementContent(value); } else { //This shouldn't be possible throw new IllegalArgumentException("Unknown encoding: " + encoding); } return retVal; }
protected String encode(String value, String encoding) { String retVal = null; if (encoding.equalsIgnoreCase("url")) { retVal = URLEncoder.DEFAULT.encode(value, StandardCharsets.UTF_8); } else if (encoding.equalsIgnoreCase("none")) { retVal = value; } else if (encoding.equalsIgnoreCase("entity")) { retVal = Escape.htmlElementContent(value); } else { //This shouldn't be possible throw new IllegalArgumentException("Unknown encoding: " + encoding); } return retVal; }
writer.print(Escape.htmlElementContent(servletName)); if ((mappings != null) && (mappings.length > 0)) { writer.print(" [ "); for (int i = 0; i < mappings.length; i++) { writer.print(Escape.htmlElementContent(mappings[i])); if (i < mappings.length - 1) { writer.print(" , ");
protected static boolean validateContextName(ContextName cn, PrintWriter writer, StringManager sm) { // ContextName should be non-null with a path that is empty or starts // with / if (cn != null && (cn.getPath().startsWith("/") || cn.getPath().equals(""))) { return true; } String path = null; if (cn != null) { path = Escape.htmlElementContent(cn.getPath()); } writer.println(sm.getString("managerServlet.invalidPath", path)); return false; }
writer.print(Escape.htmlElementContent(webModuleName)); writer.print("</a>"); if (iterator.hasNext()) {
protected static boolean validateContextName(ContextName cn, PrintWriter writer, StringManager sm) { // ContextName should be non-null with a path that is empty or starts // with / if (cn != null && (cn.getPath().startsWith("/") || cn.getPath().equals(""))) { return true; } String path = null; if (cn != null) { path = Escape.htmlElementContent(cn.getPath()); } writer.println(sm.getString("managerServlet.invalidPath", path)); return false; }
private void handleMissingResource(HttpServletRequest request, HttpServletResponse response, String jspUri) throws ServletException, IOException { String includeRequestUri = (String)request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI); if (includeRequestUri != null) { // This file was included. Throw an exception as // a response.sendError() will be ignored String msg = Localizer.getMessage("jsp.error.file.not.found",jspUri); // Strictly, filtering this is an application // responsibility but just in case... throw new ServletException(Escape.htmlElementContent(msg)); } else { try { response.sendError(HttpServletResponse.SC_NOT_FOUND, request.getRequestURI()); } catch (IllegalStateException ise) { log.error(Localizer.getMessage("jsp.error.file.not.found", jspUri)); } } }
writer.print(Escape.htmlElementContent(servletName)); if ((mappings != null) && (mappings.length > 0)) { writer.print(" [ "); for (int i = 0; i < mappings.length; i++) { writer.print(Escape.htmlElementContent(mappings[i])); if (i < mappings.length - 1) { writer.print(" , ");
Escape.htmlElementContent(path))); throw new IllegalArgumentException(smClient.getString( "managerServlet.noContext", Escape.htmlElementContent(cn.getDisplayName())));
Escape.htmlElementContent(path))); throw new IllegalArgumentException(smClient.getString( "managerServlet.noContext", Escape.htmlElementContent(cn.getDisplayName())));
if (context == null) { writer.println(smClient.getString("managerServlet.noContext", Escape.htmlElementContent(displayPath))); return; Escape.htmlElementContent(displayPath))); return;
if (context == null) { writer.println(smClient.getString("managerServlet.noContext", Escape.htmlElementContent(displayPath))); return;
if (context == null) { writer.println(smClient.getString("managerServlet.noContext", Escape.htmlElementContent(displayPath))); return;
if (context == null) { writer.println(smClient.getString("managerServlet.noContext", Escape.htmlElementContent(displayPath))); return;
if (context == null) { writer.println(smClient.getString("managerServlet.noContext", Escape.htmlElementContent(cn.getDisplayName()))); return;
if (context == null) { writer.println(smClient.getString("managerServlet.noContext", Escape.htmlElementContent(displayPath))); return;
if (context == null) { writer.println(smClient.getString("managerServlet.noContext", Escape.htmlElementContent(cn.getDisplayName()))); return;
PrintWriter writer = getWriter(); writer.print(sm.getString("coyoteResponse.sendRedirect.note", Escape.htmlElementContent(locationUri))); flushBuffer();
PrintWriter writer = getWriter(); writer.print(sm.getString("coyoteResponse.sendRedirect.note", Escape.htmlElementContent(locationUri))); flushBuffer();