Here is a naive Java implementation for those not using Scala (like me)
public static Boolean isAjax() { String requestWithHeader = "X-Requested-With"; String requestWithHeaderValueForAjax = "XMLHttpRequest"; String[] value = request().headers().get(requestWithHeader); return value != null && value.length > 0 && value[0].equals(requestWithHeaderValueForAjax); }
source share