All of a sudden my JSF 2 is rendering every page twice (with Eclipse and Tomcat.) No matter how simple it is. For example:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.prime.com.tr/ui">
<h:body>
<h:outputText value="What's going on?"></h:outputText>
</h:body>
is generating a result that looks like this:
What’s going on? What’s going on?
If I put more complex stuff in there they also show up on the page twice. I tried restarting and all but no luck. So, what’s going on?
Edit:
Thanks for your answer everyone. r0ast3d I did change my web.xml to add a filter, and when I removed the entries the double vision disappeared. But I want the filter… The entries I had are like this:
<filter>
<filter-name>dontCache</filter-name>
<filter-class>com.company.auctions.ui.DisableCacheFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>dontCache</filter-name>
<url-pattern>*.jsf</url-pattern>
</filter-mapping>
This is the doFilter method:
public void doFilter(ServletRequest request, ServletResponse res, FilterChain chain) throws IOException, ServletException {
// TODO Auto-generated method stub
// place your code here
System.out.println("DisableCacheFilter.doFilter CALLED");
HttpServletResponse response = (HttpServletResponse) res;
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
response.setHeader("Pragma", "no-cache"); // HTTP 1.0.
response.setDateHeader("Expires", 0); // Proxies.
chain.doFilter(request, response);
// pass the request along the filter chain
chain.doFilter(request, response);
}
What am I doing wrong?
The answer is right there in your
doFiltermethod. You are callingchain.doFilter(request, response)twice.