Other then putting a comment or a hidden variable as part of own JSP page, is it possible programmatically to find out what it is?
If so, how can I reference own file name inside JSP?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use
to obtain the part of the request/forward URI which matched the
JspServlet. This works regardless of if the JSP is been requested standalone or been forwarded by a front controller servlet.In JSP files which are been included by another JSP, instead use
You can’t really obtain the JSP original file name in any way as it’s been generated to a servlet class. You can however obtain the (simple) class name of the generated servlet class as follows:
When using Jasper as JSP compiler (as is been used in Tomcat and clones), this defaults to
filename_jsp(with underscore instead of period). This may or may not be sufficient as it tight-couples the code to a specific container.