Some Basics in JSP Documents
[nobr]With my first steps in JSP Documents I am a little irritated. It starts with the basic rules for printing out a variable. Imagine I have a variable defined called 'result'. Now I try to print it out, therefore I use:
<jsp:expression>result</jsp:expression>
This works quitze well. Now theres a second possibility like that (from a tutorial):
<c:forEach var="i" begin="1" end="10">
<c:out value="${i}"/>
</c:forEach>
But that really prints ten times the String "${i}".
This result is very similiar to that approach (from the j2ee tutorial):
<c:forEach var="counter" begin="1" end="3">
<jsp:text>${counter}</jsp:text>
</c:forEach>
Besides the thing, that only "${i}" is printed I thought that the jsp:text clause is only for separating template text from jsp code/tags.
I would be very thankful for anyone who explains me the difference and application of these tags and my mistakes in using them. For completeness, heres the example jsp I wrote for that purpose:
<?xml version="1.0" encoding="UTF-8"?>
<jsp:root version="2.0"
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>NextPage</title>
</head>
<body>
hallo<br/>
<jsp:declaration>long result;</jsp:declaration>
<jsp:scriptlet>
result = Math.round(10.99d);
</jsp:scriptlet>
<c:out value="result"/>
<br/>
<jsp:expression>result</jsp:expression>
<br/>
<c:forEach var="i" begin="1" end="10">
<c:out value="${i}" />
</c:forEach>
<br/>
<c:forEach var="counter" begin="1" end="3">
<jsp:text>${counter}</jsp:text>
</c:forEach>
</body>
</html>
</jsp:root>
[/nobr]

