Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

IllegalStateException in filter(Cannot forward. Response already committed)

132 views
Skip to first unread message

davidb...@hotmail.com

unread,
Nov 26, 2007, 1:22:37 PM11/26/07
to
I am converting some web apps from WAS 5.1 to 6.1 and have encountered a problem. <br />
<br />
We use a servlet filter to imbed a web page header and footer into our web pages. The code (below - ignore the comments and debugging code ;&gt;) works fine in WAS 5.1, but in WAS 6.1 it appears that the sequence of events has changed and it no longer works. The problem appears to be related to going to a default or welcome page in a WebSphere app. <br />
<br />
Example: <br />
<br />
In WAS 5.1: After keying in <a class="jive-link-external" href="http://servername/login">http://servername/login</a> (which is forwarded to index.jsp) within the login app, this filter sees/obtains the text for the index.jsp page and wraps text around it. <br />
<p />
In WAS 6.1: After keying in <a class="jive-link-external" href="http://servername/login">http://servername/login</a> (which is forwarded to index.jsp) within the login app, this filter DOESN'T (never) see the text for the index.jsp page. It looks like WAS 6.1 is doing the forward to index.jsp after the filters are invoked. If we go directly to the page (<a class="jive-link-external" href="http://servername/login/index.jsp">http://servername/login/index.jsp</a>) the filter works. <br />
<br />
We have a lot of links in our applications where we don't code a default page and we'd prefer not to hard code links to default pages if possible. Also we don't want users having to be concerned about the individual pages they go to in an app. <br />
<br />
What's different about WAS 6.1? Is this change in behavior intentional? Do we now have to code links directly to all of our pages? We'd like to do this migration as unobtrusively as possible. <br />
<p />
Here's the code and the error (excuse the commented out and debugging code):<br />
<br />
CODE:<br />
<br />
String contentType = response.getContentType();<br />
//String contentType = wrapper.getContentType();<br />
LOGGER.debug("doFilter - Content Type: " + contentType);<br />
if (contentType != null &#38;&#38; contentType.toLowerCase().startsWith("text")) {<br />
String outStr = null;<br />
LOGGER.debug("doFilter - Wrapper Content Type: "<br />
+ contentType);<br />
if (contentType.toLowerCase().startsWith("text/html")) {<br />
CharArrayWriter caw = new CharArrayWriter();<br />
<br />
// Add header<br />
caw.write((String) header.get(language));<br />
// Add body<br />
caw.write(wrapper.toString());<br />
// Add footer<br />
caw.write((String) footer.get(language));<br />
// Write to browser<br />
outStr = caw.toString();<br />
} else {<br />
outStr = wrapper.toString();<br />
}<br />
// response.setContentLength(outStr.length());<br />
LOGGER.debug("doFilter - ContentLength: " + outStr.length());<br />
PrintWriter out = response.getWriter();<br />
boolean isComm = response.isCommitted();<br />
out.write(outStr);<br />
isComm = response.isCommitted();<br />
out.close();<br />
isComm = response.isCommitted();<br />
}<br />
ERROR: <br />
<br />
<strike>11/26/07 9:23:22:669 PST</strike> 0000002c WebApp E <a href="http://www-128.ibm.com/developerworks/forums/">Servlet Error</a>-<a class="jive-link-external" href="http://Cannot forward. Response already committed.">http://Cannot forward. Response already committed.</a>: java.lang.IllegalStateException: Cannot forward. Response already committed.<br />
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:157)<br />
at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:555)<br />
at com.ibm.ws.wswebcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:113)

stanley...@capgemini.com

unread,
Dec 17, 2007, 7:37:16 AM12/17/07
to
Just wasted 1/2 a day with exactly the same issue - and you are right it is forwarding to the "welcome list" regardless of what the filter does. I have removed my welcome file list. This is definitely a bug.<br />
<br />
Regards<br />
Stan

barreau...@yahoo.fr

unread,
Sep 16, 2008, 9:48:07 AM9/16/08
to
Hi,


I get the same error since was 6.1. I first had HTTP 404 page cannot be found, so I regenerated the web server plugin and now I get:

[Servlet Error]-[Cannot forward. Response already committed.]: java.lang.IllegalStateException: Cannot forward. Response already committed.
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:157)
at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:581)
at com.ibm.ws.wswebcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:113)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3391)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:267)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:811)
at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1455)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:115)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:387)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:267)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:195)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:743)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:873)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1473)

a....@science-computing.de

unread,
Sep 16, 2008, 10:38:54 AM9/16/08
to
Could you show the "filter-mapping" portion of your web.xml please?
0 new messages