如何确定正在呈现哪些 JSP 页面?

发布于 2024-08-21 00:30:56 字数 197 浏览 13 评论 0原文

我正在开发一个遗留应用程序,该应用程序使用使用 嵌套的简单 JSP。

没有使用任何框架 - 只是 JSP Servlet 和过滤器。

谁能建议一种方法来跟踪正在呈现哪些 JSP 页面?

也许有一个日志,或者可能是渲染引擎(Jasper)中的一个钩子。

I'm working on a legacy application that is using simple JSPs that are nested using <jsp:include>.

No frameworks are being used - just JSP Servlets and filters.

Can anyone suggest a way to trace which JSP pages are being rendered?

Perhaps there's a log, or maybe a hook in the rendering engine (Jasper).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千仐 2024-08-28 00:30:56

创建一个仅侦听 *.jspurl-patternINCLUDE 调度程序的过滤器。

<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);
}

Create a Filter which listens on an url-pattern of *.jsp and the INCLUDE dispatcher only.

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

Get the parent page by HttpServletRequest#getServletPath() and the include page by HttpServletRequest#getAttribute() with key 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);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文