I am using the Struts Template Tag Library with Tomcat 3.3 and I am
receiving the "Cannot forward because the response has already been
committed" javax.servlet.ServletException.
I know that the cause is that some page is being flushed or written and then
I am trying do a <jsp:forward page="xxx.jsp"/>
I don't know why the pages are being flushed or how to fix the problem. I
tried upping the page buffer, but that did not solve the problem. Does
anyone know what the problem and resolution is?
These are the JSP pages with the problem:
mainTemplate.jsp
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ page errorPage="error.jsp" %>
<%@ page buffer="20kb" %>
<html:html locale="true">
<head>
<title><template:get name="title"/></title>
<link rel="stylesheet" href="css/templates.css" charset="ISO-8859-1"
type="text/css">
<html:base/>
</head>
<body background="graphics/background.gif">
<table>
<tr valign="top">
<td><template:get name="sidebar"/></td>
<td>
<table>
<tr><td><template:get name="header"/></td></tr>
<tr><td><template:get name="content"/></td></tr>
<tr><td><template:get name="footer"/></td></tr>
</table>
</td>
</tr>
</table>
</body>
</html:html>
home.jsp
<template:insert template='/mainTemplate.jsp'>
<template:put name='title' direct='true'>
<bean:message key="home.title"/>
</template:put>
<template:put name='header' content='/header.jsp' />
<template:put name='sidebar' content='/sidebar.jsp' />
<template:put name='content' content='/homeContent.jsp'/>
<template:put name='footer' content='/footer.html' />
</template:insert>
error.jsp
<%@ page buffer="12kb" %>
<%@ page isErrorPage="true"%>
<%@ page import = "org.apache.log4j.Log" %>
<%
Log logger = new Log("JSP Error Handler");
if (exception != null)
{
logger.error("JSP Error",exception);
}
else
{
logger.error("JSP Container Error, the exception object should always
be filled");
}
%>
<jsp:forward page="unavailable.jsp"/>