src/main/java/js/servlet/AppServlet.java
private static boolean isEmptyUriRequest(HttpServletRequest httpRequest) {
		if (!"GET".equals(httpRequest.getMethod())) {
			return false;
		}
		String acceptValue = httpRequest.getHeader(HttpHeader.ACCEPT);
		if (acceptValue != null && acceptValue.contains(ContentType.TEXT_HTML.getMIME())) {
			return false;
		}

		String referer = httpRequest.getHeader(HttpHeader.REFERER);
		if (referer == null) {
			return false;
		}

		StringBuilder uri = new StringBuilder(httpRequest.getRequestURI());
		String query = httpRequest.getQueryString();
		if (query != null) {
			if (query.charAt(0) != '?') {
				uri.append('?');
			}
			uri.append(query);
		}
		return referer.toLowerCase().endsWith(uri.toString().toLowerCase());
	}
private static boolean isEmptyUriRequest(HttpServletRequest httpRequest) {
		if (!"GET".equals(httpRequest.getMethod())) {
			return false;
		}
		String acceptValue = httpRequest.getHeader(HttpHeader.ACCEPT);
		if (acceptValue != null && acceptValue.contains(ContentType.TEXT_HTML.getMIME())) {
			return false;
		}

		String referer = httpRequest.getHeader(HttpHeader.REFERER);
		if (referer == null) {
			return false;
		}

		StringBuilder uri = new StringBuilder(httpRequest.getRequestURI());
		String query = httpRequest.getQueryString();
		if (query != null) {
			if (query.charAt(0) != '?') {
				uri.append('?');
			}
			uri.append(query);
		}
		return referer.toLowerCase().endsWith(uri.toString().toLowerCase());
	}
private static boolean isEmptyUriRequest ( HttpServletRequest httpRequest ) { if ( ! "GET" . equals ( httpRequest . getMethod ( ) ) ) { return false ; } String acceptValue = httpRequest . getHeader ( HttpHeader . ACCEPT ) ; if ( acceptValue != null && acceptValue . contains ( ContentType . TEXT_HTML . getMIME ( ) ) ) { return false ; } String referer = httpRequest . getHeader ( HttpHeader . REFERER ) ; if ( referer == null ) { return false ; } StringBuilder uri = new StringBuilder ( httpRequest . getRequestURI ( ) ) ; String query = httpRequest . getQueryString ( ) ; if ( query != null ) { if ( query . charAt ( 0 ) != ' ' ) { uri . append ( ' ' ) ; } uri . append ( query ) ; } return referer . toLowerCase ( ) . endsWith ( uri . toString ( ) . toLowerCase ( ) ) ; }
Detect self-referenced request URI. It seems there are browsers considering empty string as valid URL pointing to current
loaded page. If we have an <code>img</code> element with empty <code>src</code> attribute browser will try to load that
image from current URL, that is, the content of current page. This means is possible to invoke a controller many times
for a single page request.
<p>
To avoid such condition check if this request comes from the same page, i.e. referrer is current request. Note that this
is also true for <code>link</code> and <code>script</code> with empty <code>href</code>. Finally worthy to mention is
that this check is not performed on request accepting <code>text/html</code>.

@param httpRequest HTTP request.
@return true only this request is a <code>GET</code> and referrer is request itself.
Detect self - referenced request URI . It seems there are browsers considering empty string as valid URL pointing to current loaded page . If we have an <code > img< / code > element with empty <code > src< / code > attribute browser will try to load that image from current URL that is the content of current page . This means is possible to invoke a controller many times for a single page request . <p > To avoid such condition check if this request comes from the same page i . e . referrer is current request . Note that this is also true for <code > link< / code > and <code > script< / code > with empty <code > href< / code > . Finally worthy to mention is that this check is not performed on request accepting <code > text / html< / code > .