Home Jsp Simple-jsp-example Using JSTL For Finding Square



Using JSTL For Finding Square
Posted on: March 12, 2008 at 12:00 AM
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.

        

Related Tags for Using JSTL For Finding Square:
cstlattributesiohelpfindforeachjstlcorevaluetagattributeusingthisactionappjsforindexprogramvaluestoinirameachasteilitlastinitvarfrominasmouttrjesendproppsquarewhichsatkishallivgoeaandaractroavattssrithavstapalufininitialprndonomogro


More Tutorials from this section

Ask Questions?    Discuss: Using JSTL For Finding Square  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.