I want to get current page name (something like "myPage") using JSP or JSTL. How can I achieve this?
Of course, we can do something like the following to retrieve the current page name in JSP. String servletPath=request. getServletPath(); out. println(servletPath.
JSTL stands for JSP Standard Tag Library. JSTL is the standard tag library that provides tags to control the JSP page behavior. JSTL tags can be used for iteration and control statements, internationalization, SQL etc.
JSP lets you even define your own tags (you must write the code that actually implement the logic of those tags in Java). JSTL is just a standard tag library provided by Sun (well, now Oracle) to carry out common tasks (such as looping, formatting, etc.).
c:set allows to set the result of an expression in a variable within a given scope. Using this tag helps to set the property of 'JavaBean' and the values of the 'java. util. Map' object.
You can get it by HttpServletRequest#getServletPath()
.
${pageContext.request.servletPath}
You can use the JSTL functions taglib to extract the extension whenever necessary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With