4

を使用してネストされた単純なJSPを使用しているレガシーアプリケーションに取り組んでいます<jsp:include>

フレームワークは使用されていません。JSPサーブレットとフィルターのみが使用されています。

レンダリングされているJSPページを追跡する方法を誰かが提案できますか?

おそらくログがあるか、レンダリングエンジン(Jasper)にフックがあります。

4

1 に答える 1

2

とディスパッチャーのみurl-patternをリッスンするフィルターを作成します。*.jspINCLUDE

<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>

親ページを取得し、キーを使用しHttpServletRequest#getServletPath()てインクルード ページを取得します。HttpServletRequest#getAttribute()javax.servlet.include.servlet_path

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);
}
于 2010-02-11T11:52:21.200 に答える