get file name

I have a jsp file . How can I get file's name by code ?
tunhienAsked:
Who is Participating?
 
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
<%String x = request.getRequestURI();
x = x.substring(x.lastIndexOf("/"),x.length());%>

sorry use this code instead.
0
 
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
can you be clear
you want the same JSP's name in that JSP????
or you want that JSP name in some other java class.?
0
 
tunhienAuthor Commented:
you want the same JSP's name in that JSP????  <---- yes
0
 
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
<%String x = request.getRequestURI();
 x.substring(x.lastIndexOf("/"),x.length());%>

use <%=x%> where ever you want to display.

just try this and get back.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.