1 11 12 package org.eclipse.help.internal.webapp.servlet; 13 14 import java.io.*; 15 16 import javax.servlet.http.*; 17 18 import org.eclipse.help.internal.webapp.data.*; 19 20 24 public class FramesetFilter implements IFilter { 25 private static final String scriptPart1 = "<script>if( self == top ){ window.location.replace( \""; private static final String scriptPart3 = "\");}</script>"; 28 31 public OutputStream filter(HttpServletRequest req, OutputStream out) { 32 String uri = req.getRequestURI(); 33 if (uri == null || !uri.endsWith("html") && !uri.endsWith("htm")) { return out; 35 } 36 37 if ("/nftopic".equals(req.getServletPath()) || "/ntopic".equals(req.getServletPath()) || "/rtopic".equals(req.getServletPath()) || UrlUtil.isBot(req)) { 41 return out; 42 } 43 44 String noframes = req.getParameter("noframes"); if ("true".equals(noframes)) { return out; 47 } 48 49 String path = req.getPathInfo(); 50 if (path == null) { 51 return out; 52 } 53 StringBuffer script = new StringBuffer (scriptPart1); 54 for (int i; 0 <= (i = path.indexOf('/')); path = path.substring(i + 1)) { 55 script.append("../"); } 57 script.append("index.jsp?topic="); script.append(req.getPathInfo()); 59 script.append(scriptPart3); 60 try { 61 return new FilterHTMLHeadOutputStream(out, script.toString() 62 .getBytes("ASCII")); } catch (UnsupportedEncodingException uee) { 64 return out; 65 } 66 } 67 } 68 | Popular Tags |