Try turning the page buffer up really high... Like 256k or something obnoxious. It's obviously not a real solution, but it might get you by if you're on a deadline. I would try firing up a debugger and see what is generating the output. Another solution would be to try a different app server. If you're running in Tomcat, try Jetty to see if that helps you narrow down the issue.
-Wes On Thursday 21 May 2009 09:57:20 am Hermann X Lau wrote: > Hi, > > I tried out your suggestions and I am still getting this exception. I even > put everything in the JSP in one line and mad sure there were no > whitespaces. > > <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%><%@ > page contentType="text/html" import="org.apache.log4j.Logger"%><%final > Logger log = > Logger.getLogger("index.jsp");log.debug("begin");%><logic:forward > name="welcome" /> > > Any other ideas? > > -----Original Message----- > From: Wes Wannemacher [mailto:w...@wantii.com] > Sent: Wednesday, May 20, 2009 4:48 PM > To: Struts Users Mailing List > Subject: Re: IllegalStateException: Cannot forward. Response already > committed. > > The JSP compiler simple turns those <% %> tags inside out and > everything outside of those tags is a string with an out.print... In > your case, the first two things in the file generate returns... > Whitespace is significant... Let me see if I can make it visually more > understandable > > Index.jsp > <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%> > <---- RIGHT HERE, You will get a out.print("\n"); > <%@ page contentType="text/html" import="org.apache.log4j.Logger"%> > <----- SAME HERE > <% > > Hopefully it doesn't get all wrapped and screwed up. > > You might be wondering now, why does it work sometimes and not > others... Well, the IllegalStateException is only thrown if output has > been flushed, so you can get away with breaking the rules from time to > time. You can even set the page buffer variable really high so that > you reserve the right to redirect, even if you have generated some > output. > > Anyhow, try to remove whitespace, you could probably just do it this > way and have it work - > Index.jsp -> > <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %><%@ > page contentType="text/html" import="org.apache.log4j.Logger" > %><% > final Logger log = Logger.getLogger("index.jsp"); > log.debug("begin"); > %><logic:forward name="welcome" /> > > > On Wed, May 20, 2009 at 4:39 PM, Hermann X Lau > > <hermann.x....@jpmchase.com> wrote: > > Thanks in advance for any help on this... > > > > I understand we get this exception when the JSP attempts to write to the > > print stream after the response has been committed but I don't see how > > this is occurring in my situation since my JSP just contains a simple > > forward. > > > > Index.jsp > > <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%> > > <%@ page contentType="text/html" import="org.apache.log4j.Logger"%> > > <% > > final Logger log = Logger.getLogger("index.jsp"); > > log.debug("begin"); > > %> > > <logic:forward name="welcome" /> > > > > Here is my action class (note that in my logs, this exception occurs even > > before the execute method is called!): public class ChoiceAction extends > > StrutsAction { > > > > public ActionForward execute(ActionMapping mapping, > > ActionForm form, HttpServletRequest request, HttpServletResponse > > response) throws Exception { log4j.debug("execute"); > > ManifestChoiceFormBean choiceForm = > > (ManifestChoiceFormBean) form; Connection conn = > > DAOUtils.getConnection("jdbc/OSURptDb"); > > > > try { > > RenderRequest req = > > (RenderRequest)request.getAttribute("javax.portlet.request"); String > > sites = getResources(request).getMessage("upsws.site.list." + > > req.getPreferences().getValue("SITE_IND","").toLowerCase()); > > log4j.debug(sites); IMailManifestDAO dao = > > DAOBuilder.buildMailManifestDAO(conn); boolean uspsActive = > > dao.uspsJobsExist(sites); choiceForm.setUspsActive(uspsActive); > > log4j.info("USPS link is " + ((uspsActive) ? " active": " not active")); > > > > return > > mapping.findForward("next"); > > > > } finally { > > > > DAOUtils.closeConnection(conn); } > > } > > static final Logger log4j = > > Logger.getLogger(ChoiceAction.class); } > > > > log: > > INFO : 2009-05-20 16:26:18,581 > > com.bbb.adf.controller.WpsStrutsPortletOSU:WpsStrutsPortletOSU init() > > using URL = file:/usr/WebSphere/wps61/wp_profile/installedApps/ret7a15 > > 9/PA_MailManifest.ear/MailManifest.war/WEB-INF/classes/log4j.properties > > DEBUG: 2009-05-20 16:26:19,264 index.jsp:begin > > ERROR: 2009-05-20 16:26:19,713 > > com.bbb.exceptions.DefaultHandler:Exception caught by default handler. > > javax.portlet.PortletException: javax.portlet.PortletException: > > javax.servlet.jsp.JspException: Exception forwarding for name welcome: > > java.lang.IllegalStateException: Cannot forward. Response already > > committed. > > at > > com.ibm.portal.struts.command.StrutsViewJspCommand.includeURL(StrutsViewJ > >spCommand.java:192) at > > com.ibm.portal.struts.command.StrutsViewJspCommand.execute(StrutsViewJspC > >ommand.java:154) .... > > Caused by: > > javax.portlet.PortletException: javax.servlet.jsp.JspException: Exception > > forwarding for name welcome: java.lang.IllegalStateException: Cannot > > forward. Response already commit ted. > > at > > com.ibm.ws.portletcontainer.core.impl.PortletRequestDispatcherImpl.includ > >e(PortletRequestDispatcherImpl.java:125) at > > com.ibm.ws.portletcontainer.core.impl.PortletRequestDispatcherImpl.includ > >e(PortletRequestDispatcherImpl.java:230) at > > com.ibm.wps.standard.struts.util.WpsStrutsUtil.include(WpsStrutsUtil.java > >:2242) at > > com.ibm.portal.struts.command.StrutsViewJspCommand.includeURL(StrutsViewJ > >spCommand.java:186) ... 240 more > > Caused by: > > javax.servlet.jsp.JspException: Exception forwarding for name welcome: > > java.lang.IllegalStateException: Cannot forward. Response already > > committed. at > > org.apache.struts.taglib.logic.ForwardTag.doEndTag(ForwardTag.java:173) > > at com.ibm.struts.taglib.logic.ForwardTag.doEndTag(ForwardTag.java:94) > > ... > > DEBUG: 2009-05-20 16:26:19,946 com.bbb.ui.actions.ChoiceAction:execute > > DEBUG: 2009-05-20 16:26:20,234 com.bbb.ui.actions.ChoiceAction:CPC,CPC-OH > > INFO : 2009-05-20 16:26:20,254 com.bbb.ui.actions.ChoiceAction:USPS link > > is not active > > > > > > I am using WebSphere Portal 6.1 > > -- Wes Wannemacher Author - Struts 2 In Practice Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more http://www.manning.com/wannemacher --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org