Get the file name of the source JSP file (even if it is included)

I am trying to do some debugging of JSP files containing several levels of nested inclusions.

eg.

foo.jsp
  <%@ include file="bar.jsp"%>

  bar.jsp
    <%@ include file="baz.jsp"%>

    baz.jsp
      <%@ include file="boz.jsp"%>

To determine where a particular file is actually included, I placed a simple line to display a javascript alert in different files so that I can catch it when the page is displayed.

eg. (formatted for multiple lines for reading)

<script type="text/javascript">
  alert('Accessing File: <%=this.getName()%>' +
    '\n\nCompiled as: <%=pageContext.getPage().getClass().getName()%>' +
    '\n\nRequested by: <%=request.getRequestURI()%>');
</script>

So, ideally, what I want to see, if I put this in baz.jsp, is:

File Access: baz.jsp

Compiled as: _foo__jsp.java

Requested: foo.jsp

, <%@include%> JSP , , " foo".

, /hardcode , .

- "" JSP... ?

+3
1

<jsp:include> RequestDispatcher.include(..) , . .

+2

Source: https://habr.com/ru/post/1731565/


All Articles