Home Jsp Simple-jsp-example Using JSTL For Finding Square
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

Using JSTL For Finding Square

Advertisement
In this program we are going to find out the square of values from 1 to 10. But the approach we are taking to finding out the square is the JSTL.

Using JSTL For Finding Square

        

In this program we are going to find out the square of values from 1 to 10. But the approach we are taking to finding out the square is the JSTL. 

We are using the <c:forEach> core action tag of jstl which will help us to find the square of the values. We are going to find out the square from 1 to 10 which we will give in the attributes of the <c:forEach>. The initial value will be given to attribute var and the last index upto which we have to find out the square will be given in the attribute end.

The code of the program is given below:

 

 

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<html>
<body>
<table>
<tr><b><th>Values</th>
<th>Square</th></tr></b>
<c:forEach var="x" begin="0" end="10" step="1">
<tr><td><c:out value="${x}"/></td>
<td><c:out value="${x * x}"/></td></tr>
</c:forEach>
</table>
</body>
</html>

The output of the program is given below:

Download this example.

        

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 12, 2008

Related Tutorials

Ask Questions?    Discuss: Using JSTL For Finding Square  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com