Created
July 19, 2011 15:33
-
-
Save dennishall/1092800 to your computer and use it in GitHub Desktop.
Log JSP Include File Paths as HTML Comments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// replace "projectName" with your actual project name | |
package com.projectName.filters; | |
import javax.servlet.Filter; | |
import javax.servlet.FilterChain; | |
import javax.servlet.FilterConfig; | |
import javax.servlet.ServletRequest; | |
import javax.servlet.ServletResponse; | |
import java.io.IOException; | |
import java.io.PrintWriter; | |
import javax.servlet.ServletException; | |
public class LogFilePathAsHTMLComment implements Filter | |
{ | |
private FilterConfig filterConfig; | |
public void doFilter (ServletRequest request, | |
ServletResponse response, | |
FilterChain chain) | |
{ | |
PrintWriter out; | |
String __jspName = (String) request.getAttribute("javax.servlet.include.servlet_path"); | |
try | |
{ | |
out = response.getWriter(); | |
out.println("<!-- START: " + __jspName + " -->"); | |
chain.doFilter (request, response); | |
out.println("<!-- END: " + __jspName + " -->"); | |
} catch(IOException io) { | |
System.out.println ("IOException raised in LogFilePathAsHTMLComment"); | |
} catch(ServletException se) { | |
System.out.println ("ServletException raised in LogFilePathAsHTMLComment"); | |
} | |
} | |
public FilterConfig getFilterConfig() | |
{ | |
return this.filterConfig; | |
} | |
public void setFilterConfig (FilterConfig filterConfig) | |
{ | |
this.filterConfig = filterConfig; | |
} | |
@Override | |
public void destroy() { | |
// TODO Auto-generated method stub | |
// this.property = null; | |
} | |
@Override | |
public void init(FilterConfig arg0) throws ServletException { | |
// TODO Auto-generated method stub | |
// not sure what to do here. | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- // replace "projectName" with your actual project name --> | |
<filter> | |
<filter-name>LogFilePathAsHTMLComment</filter-name> | |
<filter-class>com.projectName.filters.LogFilePathAsHTMLComment</filter-class> | |
</filter> | |
<filter-mapping> | |
<filter-name>LogFilePathAsHTMLComment</filter-name> | |
<url-pattern>*.jsp</url-pattern> | |
<dispatcher>INCLUDE</dispatcher> | |
</filter-mapping> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment