コード例 #1
0
 @Override
 public String getContextPath() {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (String) doPrivileged("getContextPath", null);
   } else {
     return context.getContextPath();
   }
 }
コード例 #2
0
 @Override
 public void sendRedirect(final String location) throws IOException {
   setStatus(302);
   String realPath;
   if (location.startsWith("/")) {
     realPath = location;
   } else {
     String current = exchange.getExchange().getRelativePath();
     int lastSlash = current.lastIndexOf("/");
     if (lastSlash != -1) {
       current = current.substring(0, lastSlash + 1);
     }
     realPath =
         servletContext.getContextPath() + CanonicalPathUtils.canonicalize(current + location);
   }
   String host = exchange.getExchange().getRequestHeaders().getFirst(Headers.HOST);
   if (host == null) {
     host = exchange.getExchange().getDestinationAddress().getAddress().getHostAddress();
   }
   String loc = exchange.getExchange().getRequestScheme() + "://" + host + realPath;
   exchange.getExchange().getResponseHeaders().put(Headers.LOCATION, loc);
 }