Can you get jsp file name using taglib in taglib code

Is it possible to get jsp file name using taglib from java code?

those.

public int doStartTag() throws JspException 
{
    try
    {
        String xxx = pageContext.?

Where xxx will get the jsp file name (which, of course, could be an include include file)

w / h

+3
source share
2 answers

It is not possible to get the name of the JSP file simply because it was compiled at this point, and you are dealing with a compiled version, not the original JSP file.

You can get the name of the JSP class compiled in

pageContext.getPage().getClass().getName();

and try to get the JSP name from it, but the naming scheme is different between the JSP containers.

+3
source

You can get the name and path to the JSP file:

String jspFilePath = ((Servlet)pageContext.getPage()).getServletConfig().getServletName();
+1
source

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


All Articles