Discussions

Web tier: servlets, JSP, Web frameworks: Struts tiles problem

  1. Struts tiles problem (2 messages)

    Hi all: I'm using tiles for my site. Inside the template I have inserted a scriplet that, in error case (when a session bean is absent, for example), forward to the error page.

    This is the template:
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
    <%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>


    <HTML>
    <logic:notPresent name="stack">
    <jsp:forward page="../do/uscitaDialogo"/>
    </logic:notPresent>

    This one of the page:
    <%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles"%>
    <tiles:insert page="/templates/templatepaginatransazionale.jsp" flush="false">
     <tiles:put name="corpoPagina" value="/autocarro/autocarro000body.jsp"/>
    ...

    What I get (when an error occurs and the scriplet is invoked) is the error page, with the message: Cannot forward after response has been committed

    If I don't use tiles, but jsp only, everything works fine (the client is forwarded to the correct page).

    Any suggest? Thanks

    Threaded Messages (2)

  2. none[ Go to top ]

    Hi,


    When forwarding the request, Tiles does not check the status of the response before forwarding it, because Tiles internally includes the JSP pages in the response and commits the response after the first forward and then tries to forward again to the next Tiles include JSP.

    I would sugget try using jsp:include in the templeate or explicitly check if yor responce is commited in your action class.

    or you can configure a global forward to system error page in struts config and check for that session bean in action class and forward to this page.

     or

    You can configure error page in web.xml (more generic)
  3. Tiles Commit Problem[ Go to top ]

    Hi,

    I've been searching for a reason why tiles commits on an <tiles:insert.... and more importantly is there any way to turn prevent tiles from committing the response? Its quite frustrating, since some of my "tiles" have forwarding in them based on certain conditions and it seems that by default tiles always commits the response. Why? Tiles just includes content, and includes don't nesseccarily commit thie responses.... right?