src/org/ohmage/jee/filter/GzipFilter.java
private boolean doFilter(
			final HttpServletRequest httpRequest,
			final HttpServletResponse httpResponse) {

		// Create a reference to the result.
		Map<String, String[]> result = null;
		
		// Get the "Content-Encoding" headers.
		Enumeration<String> contentEncodingHeaders = 
				httpRequest.getHeaders(KEY_CONTENT_ENCODING);
		
		// Look for a GZIP content encoding header.
		boolean containsGzipContentEncoding = false;
		while(contentEncodingHeaders.hasMoreElements()) {
			// If one is found, gunzip the request.
			if(VALUE_GZIP.equals(contentEncodingHeaders.nextElement())) {
				containsGzipContentEncoding = true;
				break;
			}
		}
		
		// If the "Content-Encoding" header was given and its value was "gzip",
		// then we decode the parameters.
		if(containsGzipContentEncoding) {
			result = gunzipRequest(httpRequest, httpResponse);
		}
		// If no "Content-Encoding" header was given, then use the parameters
		// that our servlet container decoded for us.
		else {
			result = httpRequest.getParameterMap();
			
			if(result == null) {
				LOGGER
					.warn(
						"The servlet container failed to create a parameter map.");
				httpResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST);
			}
		}
		
		// If our GZIP decoding failed or the HTTP servlet request couldn't
		// generate a map, as opposed to just generating an empty map, we 
		// should return that we failed.
		if(result == null) {
			return false;
		}
		// Otherwise, we have successfully retrieved the parameter map, and
		// we should save it to the request and return success.
		else {
			// HT: printout the result --- debugging
			/*
			for (String key : result.keySet()){
				String msg = "HT: key=" + key + ", value=";
				for (String value : result.get(key))
					msg += value + ", ";
				LOGGER.debug(msg);
			}
			 */
			// Save the parameter map as an element of the request.
			httpRequest.setAttribute(ATTRIBUTE_KEY_PARAMETERS, result);
			return true;
		}
		
//		httpRequest
//			.setAttribute(
//				ATTRIBUTE_KEY_PARAMETERS,
//				httpRequest.getParameterMap());
//		return true;
	}
/**
	 * Retrieves the parameters from the request and saves them as a property
	 * with the request. The property's key is
	 * {@value #ATTRIBUTE_KEY_PARAMETERS}.
	 * 
	 * @param httpRequest The HTTP request that needs to check if the
	 * 					  {@value #KEY_CONTENT_ENCODING} header is
	 * 					  {@value #VALUE_GZIP}.
	 * 
	 * @param httpResponse The HTTP response, which is not used.
	 * 
	 * @return Returns true if a parameter map was successfully 
	 * 		   created / retrieved and saved as part of the request; false,
	 * 		   otherwise. If false is returned, the request should no longer be
	 * 		   processed as an error code should have been set that failed it.
	 */
Retrieves the parameters from the request and saves them as a property
with the request. The property's key is
#ATTRIBUTE_KEY_PARAMETERS.

@param httpRequest The HTTP request that needs to check if the
#KEY_CONTENT_ENCODING header is
#VALUE_GZIP.

@param httpResponse The HTTP response, which is not used.

@return Returns true if a parameter map was successfully
created / retrieved and saved as part of the request; false,
otherwise. If false is returned, the request should no longer be
processed as an error code should have been set that failed it.
Retrieves the parameters from the request and saves them as a property with the request . The property ' s key is #ATTRIBUTE_KEY_PARAMETERS . @param httpRequest The HTTP request that needs to check if the #KEY_CONTENT_ENCODING header is #VALUE_GZIP . @param httpResponse The HTTP response which is not used . @return Returns true if a parameter map was successfully created / retrieved and saved as part of the request ; false otherwise . If false is returned the request should no longer be processed as an error code should have been set that failed it .
private boolean doFilter(
			final HttpServletRequest httpRequest,
			final HttpServletResponse httpResponse) {
		Map<String, String[]> result = null;
		Enumeration<String> contentEncodingHeaders = 
				httpRequest.getHeaders(KEY_CONTENT_ENCODING);
		boolean containsGzipContentEncoding = false;
		while(contentEncodingHeaders.hasMoreElements()) {
			if(VALUE_GZIP.equals(contentEncodingHeaders.nextElement())) {
				containsGzipContentEncoding = true;
				break;
			}
		}
		if(containsGzipContentEncoding) {
			result = gunzipRequest(httpRequest, httpResponse);
		}
		else {
			result = httpRequest.getParameterMap();
			if(result == null) {
				LOGGER
					.warn(
						"The servlet container failed to create a parameter map.");
				httpResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST);
			}
		}
		if(result == null) {
			return false;
		}
		else {
			/*
			for (String key : result.keySet()){
				String msg = "HT: key=" + key + ", value=";
				for (String value : result.get(key))
					msg += value + ", ";
				LOGGER.debug(msg);
			}
			 */
			httpRequest.setAttribute(ATTRIBUTE_KEY_PARAMETERS, result);
			return true;
		}
	}
private boolean doFilter ( final HttpServletRequest httpRequest , final HttpServletResponse httpResponse ) { Map < String , String [ ] > result = null ; Enumeration < String > contentEncodingHeaders = httpRequest . getHeaders ( KEY_CONTENT_ENCODING ) ; boolean containsGzipContentEncoding = false ; while ( contentEncodingHeaders . hasMoreElements ( ) ) { if ( VALUE_GZIP . equals ( contentEncodingHeaders . nextElement ( ) ) ) { containsGzipContentEncoding = true ; break ; } } if ( containsGzipContentEncoding ) { result = gunzipRequest ( httpRequest , httpResponse ) ; } else { result = httpRequest . getParameterMap ( ) ; if ( result == null ) { LOGGER . warn ( "The servlet container failed to create a parameter map." ) ; httpResponse . setStatus ( HttpServletResponse . SC_BAD_REQUEST ) ; } } if ( result == null ) { return false ; } else { /*
			for (String key : result.keySet()){
				String msg = "HT: key=" + key + ", value=";
				for (String value : result.get(key))
					msg += value + ", ";
				LOGGER.debug(msg);
			}
			 */ httpRequest . setAttribute ( ATTRIBUTE_KEY_PARAMETERS , result ) ; return true ; } }
Retrieves the parameters from the request and saves them as a property
 with the request.
Retrieves the parameters from the request and saves them as a property with the request .
// Create a reference to the result. // Get the "Content-Encoding" headers. // Look for a GZIP content encoding header. // If one is found, gunzip the request. // If the "Content-Encoding" header was given and its value was "gzip", // then we decode the parameters. // If no "Content-Encoding" header was given, then use the parameters // that our servlet container decoded for us. // If our GZIP decoding failed or the HTTP servlet request couldn't // generate a map, as opposed to just generating an empty map, we  // should return that we failed. // Otherwise, we have successfully retrieved the parameter map, and // we should save it to the request and return success. // HT: printout the result --- debugging // Save the parameter map as an element of the request. //		httpRequest //			.setAttribute( //				ATTRIBUTE_KEY_PARAMETERS, //				httpRequest.getParameterMap()); //		return true;