public void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { chain.doFilter(request, response); try { Context context = Context.getContext(); context.put("request", request); context.put("response", response); WebEngine.getEngine() .getTemplate(getTemplatePath(request), request.getLocale()) .render(response); } catch (ParseException e) { throw new ServletException(e.getMessage(), e); } }
private Locale getLocale() { Template template = Context.getContext().getTemplate(); if (template != null && template.getLocale() != null) { return template.getLocale(); } Object locale = resolver.get("locale"); if (locale instanceof Locale) { return (Locale) locale; } if (locale instanceof String) { return LocaleUtils.getLocale((String) locale); } return null; }
@Override public String toString() { return render(Context.getContext().getParameters()); }