Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>Early Flush</h2> <p>The responsible for not being able to manually flush the response is <a href="https://github.com/grails/grails-core/blob/bda7fde5eb748742616fcd1f4b5be9a880a9fff6/grails-web/src/main/groovy/org/codehaus/groovy/grails/web/sitemesh/GrailsPageFilter.java" rel="nofollow">GrailsPageFilter</a> filter, which wraps the response object so he can manage the response buffer.</p> <p>You can skip this filter by creating a new filter in src/java:</p> <pre><code>package com.test; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class BypassGrailsPageFilter implements Filter { private static final String ALREADY_APPLIED_KEY = "com.opensymphony.sitemesh.APPLIED_ONCE"; public void init(FilterConfig config) throws ServletException {} public void doFilter(ServletRequest rq, ServletResponse rs, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) rq; req.setAttribute(ALREADY_APPLIED_KEY, Boolean.TRUE); chain.doFilter(req, rs); } public void destroy() { } } </code></pre> <p>And add it to your web.xml (located in src/templates/war), before sitemesh filter.</p> <pre><code>&lt;filter&gt; &lt;filter-name&gt;nositemesh&lt;/filter-name&gt; &lt;filter-class&gt;com.test.BypassGrailsPageFilter&lt;/filter-class&gt; &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;nositemesh&lt;/filter-name&gt; &lt;url-pattern&gt;/path/to/controller/*&lt;/url-pattern&gt; &lt;/filter-mapping&gt; </code></pre> <p>Controller example:</p> <pre><code>class EarlyFlushController { def test() { def out = response.outputStream out &lt;&lt; '&lt;html&gt;' out &lt;&lt; '&lt;body&gt;' out.flush() (1..10).each { i -&gt; out &lt;&lt; i out.flush() Thread.sleep(1000) } out &lt;&lt; '&lt;/body&gt;' out &lt;&lt; '&lt;/html&gt;' out.flush() out.close() response.status = 200 } } </code></pre> <p>NOTE: If you cant find your web.xml try running <code>grails install-template</code> on your app dir.</p> <hr> <h2>SiteMesh</h2> <p>You can still use grails templating system by using <code>g.render()</code> and sending its output to the response outstream.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload