Pregunta

Estoy trabajando en una aplicación heredada que está utilizando JSP simples que están anidados utilizando <jsp:include>.

No se están utilizando marcos -. Sólo JSP Servlets y filtros

Puede alguien sugerir una manera de rastrear las páginas JSP están siendo prestados?

Tal vez hay un registro, o tal vez un gancho en el motor de renderizado (Jasper).

¿Fue útil?

Solución

Crear un filtro que escucha en un url-pattern de *.jsp y el despachador INCLUDE solamente.

<filter>
    <filter-name>includeFilter</filter-name>
    <filter-class>com.stackoverflow.q2242429.IncludeFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>includeFilter</filter-name>
    <url-pattern>*.jsp</url-pattern>
    <dispatcher>INCLUDE</dispatcher>
</filter-mapping>

Obtener la página principal por HttpServletRequest#getServletPath() y la incluyen página por HttpServletRequest#getAttribute() con javax.servlet.include.servlet_path clave:

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
    throws IOException, ServletException
{
    HttpServletRequest httpreq = (HttpServletRequest) request;
    String parentPage = httpreq.getServletPath();
    String includePage = (String) httpreq.getAttribute("javax.servlet.include.servlet_path");
    // Log it here?

    chain.doFilter(request, response);
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top