Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

c:forEach loop not printing out what I expect

Posted on 2012-09-17
3
Medium Priority
?
579 Views
Last Modified: 2012-09-18
Hi there. I have the following code:

<%@ page
	import="java.io.*,java.util.*,java.net.MalformedURLException,java.text.*,java.sql.*"
	session="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>CCCCC</title>
<link rel="stylesheet" href="css/style.css">
<script src="js/libs/modernizr-2.5.3.min.js"></script>
</head>

<c:forEach var="i" begin="1" end="5">
   Item <c:out value="${i}"/><p>
</c:forEach>

Open in new window


I have this jsp deployed on Websphere. When I access this page from the browser I just get this output:

Item ${i}
Item ${i}

Item ${i}

Item ${i}

Item ${i}


I was expecting 1 2 3 4 5 but that is not being printed. Any idea what could be wrong here?
0
Comment
Question by:mightyestme
  • 2
3 Comments
 
LVL 21

Expert Comment

by:Amitkumar P
ID: 38408311
Change this line  <c:forEach var="i" begin="1" end="5"> to <c:forEach var="i" begin="1" end="5" step="1" varStatus ="status">
0
 

Author Comment

by:mightyestme
ID: 38408330
Hi Amit.
I did but the output doesn't change - I have deployed this jsp on websphere app server

${i} ${i} ${i} ${i} ${i}

<%@ page
	import="java.io.*,java.util.*,java.net.MalformedURLException,java.text.*,java.sql.*"
	session="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>CCCCC</title>
<link rel="stylesheet" href="css/style.css">
<script src="js/libs/modernizr-2.5.3.min.js"></script>
</head>


<br>
<c:forEach var="i" begin="1" end="5" step="1" varStatus ="status">
<c:out value="${i}" /> 
</c:forEach>
<br>

Open in new window

0
 
LVL 21

Accepted Solution

by:
Amitkumar P earned 1500 total points
ID: 38408698
Do one thing..

Remove the compiled JSP and generated Class file from the server.
Then again redeploy..

It happens sometimes that server is not generating the servlet for the jsp and we feel that modification is not applied or code is not working.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Find out what you should include to make the best professional email signature for your organization.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question