I want to log every <jsp:include> tag.
Does the JavaServer Pages Standard Tag Library (JSTL) support logging and if so, how do I enable it?
You can implement a Filter and configure its mapping as following:
<filter>
<filter-name>logging</filter-name>
<filter-class>com.example.LoggingFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>logging</filter-name>
<url-pattern>*.jsp</url-pattern>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
This filter will intercept all RequestDispatcher.include() calls, including <jsp:include>. To get path to the included resource, use request.getAttribute("javax.servlet.include.servlet_path")
Not directly, but you could write your own tags. If you're sufficently crazy and industrious, you can write <thilo:include> tags that do <jsp:include> and call up a bit of Java code to do logging via log4j or such.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With