title: How to redirect to another page from ejs page
body: <p>my code is:</p>
  
  <pre><code>&lt;%
  var result = [];
  if(result.length&gt;0)
  {
   //do nothing
  }
  else
  {
   //redirect page to "/product-not-found"
   //window.location.replace("http://stackoverflow.com"); is not working
  }
  %&gt;
  </code></pre>
  
  <p>Note: without passing res, req from node.js controller</p>
  
  <p>when i add this code:</p>
  
  <pre><code>window.location.replace("http://stackoverflow.com");
  </code></pre>
  
  <p>it's not working for me.
  show me error:</p>
  
  <pre><code>window is not defined
      at eval (eval at compile (\node_modules\ejs\lib\ejs.js:618:12), &lt;anonymous&gt;:215:37)
      at returnedFn (\node_modules\ejs\lib\ejs.js:653:17)
      at tryHandleCache (\node_modules\ejs\lib\ejs.js:251:36)
      at View.exports.renderFile [as engine] (\node_modules\ejs\lib\ejs.js:482:10)
      at View.render (\node_modules\express\lib\view.js:135:8)
      at tryRender (\node_modules\express\lib\application.js:640:10)
      at Function.render (\node_modules\express\lib\application.js:592:3)
      at ServerResponse.render (\node_modules\express\lib\response.js:1012:7)
      at \controllers\productController.js:1274:8
      at \node_modules\mongoose\lib\model.js:4733:16
      at \node_modules\mongoose\lib\utils.js:263:16
      at \node_modules\mongoose\lib\aggregate.js:973:13
      at \node_modules\kareem\index.js:135:16
      at processTicksAndRejections (internal/process/task_queues.js:82:9)
  </code></pre>