Can we test XPath expression in JSP?

The tag evaluates a test XPath expression and if it is true, it processes its body. If the test condition is false, the body is ignored.

Attribute

The tag has the following attributes −

Attribute Description Required Default
select The XPath expression to be evaluated Yes None
var Name of the variable to store the condition's result No None
scope Scope of the variable specified in the var attribute No Page

Example

Following is an example that show the use of the tag −



   
      JSTL x:if Tags
   
   
      

Books Info:

                                           Padam History                ZARA                100                                        Great Mistry                NUHA                2000                             Document has at least one element.
Book prices are very high

Let us now access the above JSP, the following result will be displayed −

Books Info:
Document has at least one  element.
Book prices are very high
Updated on: 2019-07-30T22:30:25+05:30

290 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements