Login page redirect new page if sucess <p>My application uses Mithril.js and Play Framework.</p> <p>I would like to know if there is a (good) way to divide my application between mithril and play. I would like to have play renders a login.html, this login.html will only contain only the import of my mithril.js component (login.js). If the login is a success I would like play to redirect my application to another html page. This pages will contain all the imports of all my mithril's components. </p> <p>So my application will have only two html pages on the play framework side, one which imports only one mithril component and the other which import all the others components (only if credentials are checked).</p> <ol> <li><p>Play router : </p> <p>GET / controllers.Index.index</p></li> <li><p>Play controller : </p> <p>def index = Action { Ok(views.html.login()) }</p></li> <li><p>login.html</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;title&gt;IHM&lt;/title&gt; StylesSheet import.. &lt;/head&gt; &lt;body id="app" class="body"&gt; &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/mithril/0.2.2-rc.1/mithril.min.js"&gt;&lt;/script&gt; &lt;script src="@routes.Assets.versioned("javascripts/claravista/login.js")" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; m.route.mode = "pathname"; m.route(document.getElementById('app'), "/", { "/": login, }); &lt;/script&gt; &lt;/body&gt; </code></pre></li> <li><p>Mithril ask play check credentials (in component login)</p> <p>m.request({method: "PUT", url: "/check-user", data : login.user }).then(returnCall);</p></li> <li><p>Case Credentials false : ask again (I already did this part)</p></li> <li><p>Case Credentials true : redirect to another html page (<strong>How to do this?</strong>)</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;title&gt;IHM&lt;/title&gt; &lt;/head&gt; &lt;body id="appmain" class="body"&gt; &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/mithril/0.2.2-rc.1/mithril.min.js"&gt;&lt;/script&gt; ALL MY MITHRIL COMPONENTS IMPORT &lt;script type="text/javascript"&gt; m.route.mode = "pathname"; m.route(document.getElementById('appmain'), "/main", { "/main": main, }); &lt;/script&gt; </code></pre> <p> </p></li> </ol> <p>How can I redirect to another html page after credentials are checked? Is there a better way to prevent the server to send all the JavaScript files before the user is logged?</p>