@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpServletRequest = ((HttpServletRequest) request); HttpServletMapping mapping = ((HttpServletRequest) request).getHttpServletMapping(); String resourceURI = mapping.getMatchValue(); if (mapping.getServletName().equals("jsp")) { // Push resources resourceCache.keySet().stream() .filter(resourceURI::contains) .findFirst() .ifPresent(s -> resourceCache.get(s) .forEach(path -> httpServletRequest.newPushBuilder().path(path).push())); // create empty resource list if absent resourceCache.putIfAbsent(resourceURI, Collections.newSetFromMap(new ConcurrentHashMap<>())); } else { // Add resource resourceCache.keySet().stream() .filter(httpServletRequest.getHeader("Referer")::contains) .forEach(page -> resourceCache.get(page).add(resourceURI)); } chain.doFilter(request, response); }
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { HttpServletMapping mapping = request.getHttpServletMapping(); response.getWriter() .append("Mapping match:") .append(mapping.getMappingMatch().name()) .append("\n") .append("Match value:") .append(mapping.getMatchValue()) .append("\n") .append("Pattern:") .append(mapping.getPattern()); }
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpServletMapping servletMapping = request.getHttpServletMapping(); response.getWriter() .append("<html><body>") .append("Value Matched: ").append(servletMapping.getMatchValue()) .append("<br/>") .append("Pattern Used: ").append(servletMapping.getPattern()) .append("<br/>") .append("Mapping Matched: ").append(servletMapping.getMappingMatch().name()) .append("<br/>") .append("</body></html>"); }
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpServletMapping servletMapping = request.getHttpServletMapping(); response.getWriter() .append("<html><body>") .append("Value Matched: ").append(servletMapping.getMatchValue()) .append("<br/>") .append("Pattern Used: ").append(servletMapping.getPattern()) .append("<br/>") .append("Mapping Matched: ").append(servletMapping.getMappingMatch().name()) .append("<br/>") .append("Servlet Name: ").append(servletMapping.getServletName()) .append("<br/>") .append("</body></html>"); }
public static void printCurrentMappingDetails(HttpServletRequest request, PrintWriter out) throws IOException { HttpServletMapping forwardMapping = (HttpServletMapping) request.getAttribute(RequestDispatcher.FORWARD_MAPPING); HttpServletMapping includeMapping = (HttpServletMapping) request.getAttribute(RequestDispatcher.INCLUDE_MAPPING); HttpServletMapping asyncMapping = (HttpServletMapping) request.getAttribute(AsyncContext.ASYNC_MAPPING); out.print("<p> " + request.getHttpServletMapping() + "</p>"); out.print("<p> FORWARD_MAPPING: " + forwardMapping + "</p>"); out.print("<p> INCLUDE_MAPPING: " + includeMapping + "</p>"); out.print("<p> ASYNC_MAPPING: " + asyncMapping + "</p>"); out.print("<hr />"); }