Common.java 828 B

123456789101112131415161718192021222324252627282930
  1. package hello;
  2. import org.apache.commons.lang3.*;
  3. import com.fasterxml.jackson.databind.*;
  4. /**
  5. * Some common functionality and constants used by the Servlet tests.
  6. */
  7. public class Common
  8. {
  9. // Constants for setting the content type.
  10. protected static final String HEADER_CONTENT_TYPE = "Content-Type";
  11. protected static final String CONTENT_TYPE_JSON = "application/json";
  12. protected static final String CONTENT_TYPE_HTML = "text/html";
  13. // Jackson encoder, reused for each response.
  14. protected static final ObjectMapper MAPPER = new ObjectMapper();
  15. /**
  16. * Use the OWASP ESAPI HTML encoder to process an untrusted String into a
  17. * form suitable for rendering in output HTML.
  18. */
  19. public static String render(String input)
  20. {
  21. return StringEscapeUtils.escapeHtml4(input);
  22. }
  23. }