Then I mapped it this way :
<filter>
<filter-name>contentTypePatchFilter</filter-name>
<description>Filtro per evitare "IllegalStateException: Attempt to change ContentType after calling getWriter()" su BEA WLS81</description>
<filter-class>it.archeometra.flotte.presentation.setContentTypePatch.ContenTypePatchFilter </filter-class>
</filter>
<filter-mapping>
<filter-name>contentTypePatchFilter</filter-name>
<url-pattern>/app</url-pattern>
</filter-mapping>
Ignore Italian comments please :-D
Hope this help.
Paolo
On 12/10/05, Kent Tong <[EMAIL PROTECTED]
> wrote:
crafty78 <maillist <at> tapestryforums.com > writes:
>
> Is there any idea if this will be addressed, its a bit of a showstopper as i
> can't use tapestry on weblogic!
This a bug in WebLogic. Calling setContentType() after call getWriter()
is allowed by the servlet api specification:
setContentType()
This method may be called repeatedly to change content type and
character encoding. This method has no effect if called after the
response has been committed. It does not set the response's
character encoding if it is called after getWriter has been called
or after the response has been committed.
--
In fact, Tapestry has already called reset() on the response which
should clear the state (including the content type and whether
getWriter() has been called) of the response. However, I can't find
any info in the spec requiring this behavior.
--
Author of a book for learning Tapestry (http://www.agileskills2.org/EWDT )
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
package it.archeometra.flotte.presentation.setContentTypePatch; import org.apache.log4j.Logger;
import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* @author Paolo Dona
*/
public class ContenTypePatchFilter implements Filter {
Logger log = Logger.getLogger(ContenTypePatchFilter.class);
public void init(FilterConfig filterConfig) throws ServletException {
log.debug("ContenTypePatchFilter started.");
}
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
HttpServletResponse res = (HttpServletResponse) servletResponse;
NotUpsettingHttpServletResponse myResponse = new NotUpsettingHttpServletResponse(res);
filterChain.doFilter(servletRequest,myResponse);
}
public void destroy() {
log.debug("ContenTypePatchFilter stopped.");
}
}
package it.archeometra.flotte.presentation.setContentTypePatch;
import org.apache.log4j.Logger;
import javax.servlet.http.HttpServletResponseWrapper;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletOutputStream;
import java.io.PrintWriter;
import java.io.IOException;
/**
* Implementazione della response che non fa incazzare bea weblogic
* E' necesaria perchè alcune librerie quali Tapestry e Axis
* Fanno il setContentType anche dopo che la response è committata.
* Tomcat non si incazza, ma wls81 si!
* @author Paolo Dona
*/
public class NotUpsettingHttpServletResponse extends HttpServletResponseWrapper {
private Logger log = Logger.getLogger(NotUpsettingHttpServletResponse.class);
private boolean gotWriter;
private boolean gotOutputStream;
public NotUpsettingHttpServletResponse(HttpServletResponse httpServletResponse) {
super(httpServletResponse);
}
public void setContentType(String contentType) {
if (isCommitted() || gotWriter || gotOutputStream){
//log.debug("skipping response.setContentType(..);");
} else {
super.setContentType(contentType);
}
}
public PrintWriter getWriter() throws IOException {
gotWriter = true;
return super.getWriter();
}
public ServletOutputStream getOutputStream() throws IOException {
gotOutputStream = true;
return super.getOutputStream();
}
}
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
