Common.java 899 B

12345678910111213141516171819202122232425262728293031
  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_TEXT = "text/plain";
  13. protected static final String CONTENT_TYPE_HTML = "text/html";
  14. // Jackson encoder, reused for each response.
  15. protected static final ObjectMapper MAPPER = new ObjectMapper();
  16. /**
  17. * Use the OWASP ESAPI HTML encoder to process an untrusted String into a
  18. * form suitable for rendering in output HTML.
  19. */
  20. public static String render(String input)
  21. {
  22. return StringEscapeUtils.escapeHtml4(input);
  23. }
  24. }