title: How to redirect an Alfresco webscript to a different response page
body: <p>I've defined an Alfresco Repo Webscript, implemented in Java, which copies a template folder structure into a site's document repository.</p>
  
  <p>The Freemarker HTML template for this webscript is trivial</p>
  
  <pre><code>&lt;html&gt;
      &lt;body&gt;
          &lt;p&gt;Your request was successful&lt;/p&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>But I don't actually want this to be displayed to the user. I want the response page to be the site's document repository.</p>
  
  <p>So in my Java webscript code, I added this line</p>
  
  <pre><code>@Override
  protected Map&lt;String, Object&gt; executeImpl(WebScriptRequest req, Status status, Cache cache) {
      ...     
      status.setLocation("http://localhost:8081/share/page/site/my-site/documentlibrary");
      ...
  }
  </code></pre>
  
  <p>which I'd hoped would redirect the response to the url, but the page above is still being rendered.</p>
  
  <p>Looking at the code for <code>DeclarativeWebScript</code> (which my implementation class inherits from), I see this</p>
  
  <pre><code>String location = status.getLocation();
  if (location != null &amp;&amp; location.length() &gt; 0)
  {
    if (logger.isDebugEnabled())
    logger.debug("Setting location to " + location);
    res.setHeader(WebScriptResponse.HEADER_LOCATION, location);
  }
  </code></pre>
  
  <p>What am I missing to get the redirect to work?</p>