Hey,
Currently i am developing a pluggable Webapplication with virgo-server and virgo snaps. Therefore i would like to implement some kind of templating where the
host provides a general layout. If a snap is called the snap should integrate its output in the hosts template.
My approach so far is to use a filter which wrapps html around the response of every snap. My problem is that the filter that i have defined after the SnapHostFilter in the web.xml is not executed.
If i define my filter before the SnapHostFilter it gets executed but then the actual response to the client only contains the wrapping-html but not the output from the snap.
Does anybody have an idea why it is not working? or how i could implement some kind of templating that is controlled by the host?
Thanks very much
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
OutputStream out = response.getOutputStream();
out.write("<HR>PRE<HR>".getBytes());
GenericResponseWrapper wrapper = new GenericResponseWrapper((HttpServletResponse) response);
chain.doFilter(request,wrapper);
out.write(wrapper.getData());
//out.write("<HR>POST<HR>".getBytes());
out.close();
}
web.xml
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>templateFilter</filter-name>
<filter-class>de.project.bai.webapp.templating.TemplateFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>templateFilter</filter-name>
<url-pattern>/base/web/*</url-pattern>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
<filter>
<filter-name>host-filter</filter-name>
<filter-class>org.eclipse.virgo.snaps.core.SnapHostFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>host-filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>