	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {
		HttpServletRequest req = (HttpServletRequest) request;
		HttpServletResponse resp = (HttpServletResponse) response;
		String uri = req.getRequestURI();
		if (!uri.contains("/servlet/admin/media/")) {
			chain.doFilter(request, response);
			return;
		}
		try {
			PhotoService photoService = getSpringContext().getBean("photoServiceImpl", PhotoServiceImpl.class);
			String path = uri.substring(uri.indexOf("/servlet/admin/media/") + "/servlet/admin/media/".length(), uri.length());
			String scalerType = SimpleServletRequestUtils.getStringParameter(req, "scalerType", null);
			int width = SimpleServletRequestUtils.getIntParameter(req, "width", 0);
			int hight = SimpleServletRequestUtils.getIntParameter(req, "hight", 0);
			byte[] photoStream = null;
			if (StringUtils.isBlank(scalerType)) {
				photoStream = photoService.getPhoto(path, width, hight);
			} else {
				try {
					PhotoScalerType photoScalerType = PhotoScalerType.valueOf(scalerType);
					photoStream = photoService.getPhoto(path, photoScalerType);
				} catch (Exception e) {
					photoStream = photoService.getPhoto(path, -1, -1);
				}
			}
			String suffix = path.substring(path.lastIndexOf(".") + 1, path.length());
			resp.setHeader("Cache-Control", "max-age=3600, must-revalidate");
			resp.setContentType("image/" + mimeTable.get(suffix.toUpperCase()));
			resp.setCharacterEncoding("UTF-8");
			ServletOutputStream out = resp.getOutputStream();
			out.write(photoStream);
			out.close();
			return;
		} catch (Exception ex) {
			logger.error("Can not find the media item[" + uri + "]", ex);
			chain.doFilter(request, response);
		}
	}

	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {
		HttpServletRequest req = (HttpServletRequest) request;
		HttpServletResponse resp = (HttpServletResponse) response;
		String uri = req.getRequestURI();
		if (!uri.contains("/servlet/media/")) {
			chain.doFilter(request, response);
			return;
		}
		try {
			PhotoService photoService = getSpringContext().getBean("photoServiceImpl", PhotoServiceImpl.class);
			String path = uri.substring(uri.indexOf("/servlet/media/") + "/servlet/media/".length(), uri.length());
			String scalerType = SimpleServletRequestUtils.getStringParameter(req, "scalerType", null);
			int width = SimpleServletRequestUtils.getIntParameter(req, "width", 0);
			int hight = SimpleServletRequestUtils.getIntParameter(req, "hight", 0);
			byte[] photoStream = null;
			if (StringUtils.isBlank(scalerType)) {
				photoStream = photoService.getPhoto(path, width, hight);
			} else {
				try {
					PhotoScalerType photoScalerType = PhotoScalerType.valueOf(scalerType);
					photoStream = photoService.getPhoto(path, photoScalerType);
				} catch (Exception e) {
					photoStream = photoService.getPhoto(path, -1, -1);
				}
			}
			String suffix = path.substring(path.lastIndexOf(".") + 1, path.length());
			resp.setHeader("Cache-Control", "max-age=3600, must-revalidate");
			resp.setContentType("image/" + mimeTable.get(suffix.toUpperCase()));
			resp.setCharacterEncoding("UTF-8");
			ServletOutputStream out = resp.getOutputStream();
			out.write(photoStream);
			out.close();
			return;
		} catch (Exception ex) {
			logger.error("Can not find the media item[" + uri + "]", ex);
			chain.doFilter(request, response);
		}
	}
