Is there a way to get which JSP is currently rendered, with JSTL or Struts (or without)? like _ _ file _ _ in Python and PHP?
+3
A:
Well ... yes ... in a way
String __jspName = this.getClass().getSimpleName().replaceAll("_", ".");
I'm using a JSP called pre.jsp
for that which I include at the top of each JSP in my webapp:
<%@page import="org.apache.log4j.Logger"%>
<%
String __jspName = this.getClass().getSimpleName().replaceAll("_", ".");
Logger log = Logger.getLogger(this.getClass().getName());
log.info("BEGIN JSP "+__jspName);
%>
<!-- BEGIN <%=__jspName %> -->
Plus I put this at the end of each JSP:
<!-- END <%=__jspName %> --><% log.info("END JSP "+__jspName); %>
That gives me a consistend log. To make sure each JSP is "correct", I have a check in my build script which just looks for the two strings "/pre.jsp"
and `END <%=__jspName
.
Aaron Digulla
2009-05-14 13:19:14
Yeah. that was exactly the usecase I had... I guess it'll do
elzapp
2009-05-14 13:39:08