1 11 package org.apache.catalina.ssi; 12 13 14 import javax.servlet.http.HttpServletRequest ; 15 import org.apache.catalina.util.RequestUtil; 16 public class SSIServletRequestUtil { 17 25 public static String getRelativePath(HttpServletRequest request) { 26 if (request.getAttribute("javax.servlet.include.request_uri") != null) { 28 String result = (String )request 29 .getAttribute("javax.servlet.include.path_info"); 30 if (result == null) 31 result = (String )request 32 .getAttribute("javax.servlet.include.servlet_path"); 33 if ((result == null) || (result.equals(""))) result = "/"; 34 return (result); 35 } 36 String result = request.getPathInfo(); 38 if (result == null) { 39 result = request.getServletPath(); 40 } 41 if ((result == null) || (result.equals(""))) { 42 result = "/"; 43 } 44 return normalize(result); 45 } 46 47 48 61 public static String normalize(String path) { 62 if (path == null) return null; 63 String normalized = path; 64 if (normalized.indexOf('\\') >= 0) 67 normalized = normalized.replace('\\', '/'); 68 normalized = RequestUtil.normalize(path); 69 return normalized; 70 } 71 } | Popular Tags |