1 package com.icesoft.faces.webapp.http.core; 2 3 import com.icesoft.faces.webapp.http.common.Configuration; 4 import com.icesoft.faces.webapp.http.common.Request; 5 import com.icesoft.faces.webapp.http.common.Response; 6 import com.icesoft.faces.webapp.http.common.ResponseHandler; 7 import com.icesoft.faces.webapp.http.common.Server; 8 9 import java.io.PrintStream ; 10 11 public class RedirectOnJSBlocked implements Server { 12 private ResponseHandler handler; 13 14 public RedirectOnJSBlocked(Configuration configuration) { 15 try { 16 final String redirectURI = configuration.getAttribute("javascriptBlockedRedirectURI"); 17 handler = new ResponseHandler() { 18 public void respond(Response response) { 19 response.setStatus(307); 20 response.setHeader("Location", redirectURI); 21 } 22 }; 23 } catch (Exception e) { 24 handler = new ResponseHandler() { 25 public void respond(Response response) throws Exception { 26 response.setStatus(403); 27 PrintStream stream = new PrintStream (response.writeBody()); 28 stream.println("Javascript is blocked. ICEfaces cannot run."); 29 } 30 }; 31 } 32 } 33 34 public void service(final Request request) throws Exception { 35 request.respondWith(handler); 36 } 37 38 public void shutdown() { 39 } 40 } 41 | Popular Tags |