title: Unable to load new Page using window.location from java code
body: <p>I have one interceptor, in which I hv to redirect to main Page if session is invalid.
  I want to use window.location for same, but giving error.</p>
  
  <p>My Interceptor is : </p>
  
  <pre><code>@Override
      public boolean preHandle(HttpServletRequest request,
              HttpServletResponse response, Object handler) throws Exception {
          if ((null == request.getSession(false))
                  || (null == request.getSession(false).getAttribute(
                          "user"))) {
              System.out.println("user logged out...");
              ScriptEngineManager factory = new ScriptEngineManager();
              ScriptEngine engine = factory.getEngineByName("JavaScript");
  
              engine.eval("window.location='logout.do'");
          return false;
          }
          return super.preHandle(request, response, handler);
      } 
  </code></pre>
  
  <p>Error : </p>
  
  <pre><code>   javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "window" is not defined. (&lt;Unknown source&gt;#1) in &lt;Unknown source&gt; at line number 1
          at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:110)
          at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:124)
          at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247)
          at com.snstech.mocktest.util.MyInterceptor.preHandle(MyInterceptor.java:23)
          at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:761)
          at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
          at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
          at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
          at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
          at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
          at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
          at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
          at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300)
          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
          at java.lang.Thread.run(Thread.java:662)
  </code></pre>
  
  <p>Or is their any other way to do the same...</p>
  
  <p>thanks,</p>