Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get page name in JSP or JSTL?

Tags:

jsp

jstl

el

I want to get current page name (something like "myPage") using JSP or JSTL. How can I achieve this?

like image 750
Mahmoud Saleh Avatar asked May 15 '11 09:05

Mahmoud Saleh


People also ask

How to get page name in JSP?

Of course, we can do something like the following to retrieve the current page name in JSP. String servletPath=request. getServletPath(); out. println(servletPath.

Why we use JSTL in JSP?

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.

What is the difference between JSTL and JSP?

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.).

What is c set in JSTL?

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.


1 Answers

You can get it by HttpServletRequest#getServletPath().

${pageContext.request.servletPath}

You can use the JSTL functions taglib to extract the extension whenever necessary.

like image 129
BalusC Avatar answered Sep 22 '22 02:09

BalusC