C_rt:forEach help

ok. Here's some code. It won't work. I have fmt.tld and c-rt.tld in my tlds folder, included is the jsp page:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c_rt" %>
<%@ taglib uri="http://java.sun.com/jstl/format" prefix="fmt" %>
<html>
<head>
<title>JSTL Q2</title>
</head>
<body>
<h1>JSTL Question 2</h1>
<h2>How do I use JSTL?</h2>
<p>Multiplication table, 1-5</p>
<!-- Use the forEach tag to create a table -->
<table border="1">
<tr>
<td></td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td>
</tr>
<c_rt:forEach var="i" begin="1" end="5">
<tr>
<td><c_rt:out value="${i}"/></td>
<c_rt:forEach var="j" begin="1" end="5">
<td><c_rt:out value="${i*j}"/></td>
</c_rt:forEach>
</tr>
</c_rt:forEach>
</table>
</body>
</html>
and the appropriate parts of web.xml
<taglib>
<taglib-uri>http://java.sun.com/jstl/core_rt</taglib-uri>
<taglib-location>/WEB-INF/tlds/c-rt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/format</taglib-uri>
<taglib-location>/WEB-INF/tlds/fmt.tld</taglib-location>
</taglib>
any ideas would be much appreciated.....

You need to use the core tags, not the core_rt tags, if you are intending to use JSP EL.
That is:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<table border="1">
<tr>
<td></td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td>
</tr>
<c:forEach var="i" begin="1" end="5">
<tr>
<td><c:out value="${i}"/></td>
<c:forEach var="j" begin="1" end="5">
<td><c:out value="${i*j}"/></td>
</c:forEach>
</tr>
</c:forEach>
</table>
</body>
</html>Cheers, Neil

Similar Messages

  • ForEach tag problem in JSP

    I have this next code, but the forEach tag doesn't seem to work! However, the line <c:out value='${lista[1]}'/> does work. Can you help me with the problem, please?
    <%@     page
         contentType = "text/html;charset=iso-8859-1"
         session="true"
         language="java"
         import = "java.lang.*"
         import = "java.util.*"
    %>
    <c_rt:if test='<%= request.getParameter("hinicio") != null %>'>
              <%
                   ArrayList Valores = new ArrayList(4);
                   Valores.add(request.getParameter("text1"));
                   Valores.add(request.getParameter("text2"));
                   Valores.add(request.getParameter("text3"));
                   Valores.add(request.getParameter("text4"));
                   Valores.add(request.getParameter("text5"));
                   pageContext.setAttribute("lista", Valores);
              %>
              <c:forEach var='x' items='<%= Valores %>'>
                   <c:out value='${x}'/>
              </c:forEach>
    <c:out value='${lista[1]}'/>
    </c_rt:if>
    <html>
    <head>
         <title>Tarea</title>
         <script type="text/javascript">
              function Inicio()
                   forma.hinicio.value = "ok";
                   forma.submit();
         </script>
    </head>
    <body>
    <form name="forma" method="post" action="Tarea.jsp">    //Redirects to itself
         <input type="hidden" name="hinicio">
         <center>
         <br>
         <input type="text" name="text1" value="0">
         <br>
         <input type="text" name="text2" value="0">
         <br>
         <input type="text" name="text3" value="0">
         <br>
         <input type="text" name="text4" value="0">
         <br>
         <input type="text" name="text5" value="0">
         <br>
         <br>
         <input type="text" name="rango1" value="0">   <input type="text" name="rango2" value="0">
         <br>
         <br>
         <input type="button" value="Aceptar" onClick="Inicio()">
         <br>
         <br>
         <input type="text" name="resultado" value="0">
         </center>
    </form>
    </body>
    </html>

    You seem to be using both the EL and the RT JSTL libs on the same page.
    If you are in a JSP1.2 container, then you can only use EL with the EL tags, and <%= expr %> with the rt tags.
    If you have a JSP2.0 container (eg Tomcat 5) properly configured (ie web.xml is version 2.4) then you should use JSTL1.1, which accepts both sorts of expressions. (${expr} is a runtime expression in JSP2.0)
    Try either
    <c:forEach var='x' items='${lista}'>
    or
    <c_rt:forEach var='x' items='<%= Valores %>'>

  • Nested Read only tables jdev 10.1.2

    Hi
    I need to display master detail tables on a JSP so that the there is a list of master tables and after each entry there is a list of the detail records followed by the next master record. I tried dropping both of them as read only tables and then putting the c:forEach var="Row" items="${bindings.detailView1.rangeSet} inside the
    c:forEach var="Row" items="${bindings.masterView1.rangeSet}. Unfortunately the pointer to the detail rows never seems to change and the details for the first master record are shown for every record. If I put tracing in the viewRowImpl however it shows that detail records are being accessed for every master record.
    Does anyone know how to display these detail records.
    There is a description of something I could possibly use here
    nested foreach - help
    except that it uses AF and I am using JSPs
    Thanks in advance
    Rob

    Ok... I solved it, though I don't think this is the right way.
    SOLUTION:
    I inserted a formValue into the UIX page like this:
    <formValue model="${bindings.AttributeToUpdate}"
    value="${bindings.TheValue}"
    name="VB_AttributeToUpdate" />The formValue name is very important and must start with VB_ followed by the name of the attribute to update. I figured out this by looking at the generated html code when I inserted the "AttributeToUpdate" as an editable inputtext, it uses the VB_ prefix and was the only way to get the attribute updated.
    Thanks anyway, and if someone knows of another way to do this I'd like to know it.
    Bye.
    Mensaje editado por:
    Fer Domin

  • Index printing in JSP using JSTL

    I want to print the index of an collection, as weel as the data
    right now I am doing
    <c:forEach var="codebean" items="${PROJECT_LIST}" >
      <c:out value="${codebean.name}"/>
      <input type="hidden" name="rank" value="${index}"/>  <--Print the index here
    </c:forEach>                         I know I can do this,
    <c:forEach var="index" begin="${0}" end="${fn:length(PROJECT_LIST)-1}" >but I cannot combine both,
    <c:forEach var="codebean" items="${PROJECT_LIST}" var="index" begin="${0}" end="${fn:length(PROJECT_LIST)-1}" >
    <c:out value="${codebean.name}"/>
      <input type="hidden" name="rank" value="${index}"/>  <--Print the index here
    </c:forEach>Help!!

    use the attribute varStatus of the c:forEach
    example
    <%
    int [] ts1 = new int[3];
              ts1[0] = 0;
              ts1[1] = 1;
              ts1[2] = 2;
    pageContext.setAttribute("ts1", ts1);
    %>
    <c:forEach items="${ts1}" varStatus="status" var="foo">
              <c:out value="${foo} and count is ${status.count}" which is not zero based/></br>
    </c:forEach>s

  • Urgent need help in c:forEach in JSF

    I have a problem while using loop with any UI component ex Input field
    here is my code
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <%-- jsf:codeBehind language="java" location="/JavaSource/pagecode/Loop.java" --%><%-- /jsf:codeBehind --%>
    <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@taglib uri="http://www.ibm.com/jsf/html_extended" prefix="hx"%>
    <%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c_rt"%>
    <%@taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
    <HTML>
    <HEAD>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <%@ page
    language="java"
    contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"
    %>
    <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <META name="GENERATOR" content="IBM WebSphere Studio">
    <META http-equiv="Content-Style-Type" content="text/css">
    <LINK href="theme/Master.css" rel="stylesheet" type="text/css">
    <TITLE>Loop.jsp</TITLE>
    <LINK rel="stylesheet" type="text/css" href="theme/stylesheet.css"
         title="Style">
    </HEAD>
    <f:view>
         <BODY><hx:scriptCollector id="scriptCollector1">
         <h:form styleClass="form" id="form1"><P>Place content here.<BR>
         <%
    // initialisation of string[][]
    String[] sValues = new String[5];
    for (int i=0; i<sValues.length; i++){
           sValues= "" + i;
    pageContext.setAttribute("arrayValues", sValues);
    %>
    <!--//
    // And now to test print out the values
    // -->
    <c:forEach var="row" items="${arrayValues}">
    <c:out value="${row}"/>
    <h:inputText styleClass="inputText" value='#{row}' rendered="true" >
    </h:inputText>
    <%="<br>"%>               
                   </c:forEach>
         <BR>
         </P></h:form>
         </hx:scriptCollector>
         </BODY>
    </f:view>
    </HTML>
    when i run the code nothing displayed.
    when using standared html input field, the code runs well.
    waiting for reply

    JSF dose not like DOCTYPE tag for HTML. Try removing that.
    Vaibhav

  • c:forEach use .......need help

    I am making a form of registering details of competitive exams.in this i am using the jstl for fetching the values fromthe database
    like qualification table is master table and the eligibilty table .
    these two tables are drop down list and depend on one another
    in the sense ...eligibility table when u select multiple values from it then an event onblur will make the changes in the qulaification drop down list.
    the list of values from the master tables are taken to the bean first and then into the form and also all the getter and setter methods are also there in it
    the code for it is as follows:
    bean
    private String examinationName;
         private List eligibilityList = new ArrayList();
         private List qualificationList = new ArrayList();
         private List sourceList = new ArrayList();
         public CompetitiveExamBean() {
         eligibilityList = DAOMaster.getQualificationMaster();
         if(eligibility!=null) qualificationList=DAOMaster.getQualificationDetail(eligibility);
         sourceList = DAOMaster.getSourceList();
    jsp page
    (Code for eligibility)
    <select name="eligibility" style="width:220pt" multiple size="4" onblur="changeQualification()">
    <c:forEach var="elb" items="${competitiveExamBean.eligibilityList}">
    <option value="${elb.id}"
         <c:forEach var="selEligi" items="${competitiveExamBean.eligibility}">
         <c:if test="${elb.id==selEligi}"><c:out value="selected"/></c:if></c:forEach> >
         <c:out value="${elb.value}"></c:out>
    </option>
    </c:forEach>
    </select>
    (code for qualification)
    <select multiple name="qualification" style="width:220pt">
    <c:forEach var="selq" items="${competitiveExamBean.qualificationList}">
         <option value="${selq.id}"
                   <c:forEach var="selQuali" items="${competitiveExamBean.qualification}">
                   <c:if test="${selq.id==selQuali}"><c:out value="selected"/></c:if></c:forEach> >
              <c:out value="${selq.value}"></c:out>
         </option>
    </c:forEach>
    </select>
    In the jsp page the list of eligibility is shown but the qualification list can't be displayed .........
    javascript for this is
    <script language="javascript">
    function changeQualification(){
    document.forms[0].changeQuali.value="1";
    document.forms[0].submit();
    </script>
    and there is a hidden field ---- changeQuali in the jsp page
    place help me as to where i am going wrong
    waiting for ur reply

    I am making a form of registering details of competitive exams.in this i am using the jstl for fetching the values fromthe database
    like qualification table is master table and the eligibilty table .
    these two tables are drop down list and depend on one another
    in the sense ...eligibility table when u select multiple values from it then an event onblur will make the changes in the qulaification drop down list.
    the list of values from the master tables are taken to the bean first and then into the form and also all the getter and setter methods are also there in it
    the code for it is as follows:
    bean
    private String examinationName;
         private List eligibilityList = new ArrayList();
         private List qualificationList = new ArrayList();
         private List sourceList = new ArrayList();
         public CompetitiveExamBean() {
         eligibilityList = DAOMaster.getQualificationMaster();
         if(eligibility!=null) qualificationList=DAOMaster.getQualificationDetail(eligibility);
         sourceList = DAOMaster.getSourceList();
    jsp page
    (Code for eligibility)
    <select name="eligibility" style="width:220pt" multiple size="4" onblur="changeQualification()">
    <c:forEach var="elb" items="${competitiveExamBean.eligibilityList}">
    <option value="${elb.id}"
         <c:forEach var="selEligi" items="${competitiveExamBean.eligibility}">
         <c:if test="${elb.id==selEligi}"><c:out value="selected"/></c:if></c:forEach> >
         <c:out value="${elb.value}"></c:out>
    </option>
    </c:forEach>
    </select>
    (code for qualification)
    <select multiple name="qualification" style="width:220pt">
    <c:forEach var="selq" items="${competitiveExamBean.qualificationList}">
         <option value="${selq.id}"
                   <c:forEach var="selQuali" items="${competitiveExamBean.qualification}">
                   <c:if test="${selq.id==selQuali}"><c:out value="selected"/></c:if></c:forEach> >
              <c:out value="${selq.value}"></c:out>
         </option>
    </c:forEach>
    </select>
    In the jsp page the list of eligibility is shown but the qualification list can't be displayed .........
    javascript for this is
    <script language="javascript">
    function changeQualification(){
    document.forms[0].changeQuali.value="1";
    document.forms[0].submit();
    </script>
    and there is a hidden field ---- changeQuali in the jsp page
    place help me as to where i am going wrong
    waiting for ur reply

  • ForEach items syntax help please

    This shouldn't be a problem but it is. I have a JSP. I am sending it an attribute that is a collection by calling setAttribute() on the request and then dispatching to the JSP from my front controller servlet. I want to iterate through the collection. The name of the attribute is "changeRequets" and I have tried accessing it without any scope qualifiers and with scope qualifiers and no matter what, this forEach produces no data. I have verified that the JSP is receiving data, because I've accessed the request attribute separately without JSTL. What is wrong with the following please?
       <c:forEach var="chgRequest" items="${requestScope.request.changeRequests}">
                    <tr>
                        <td>
                            <input type="radio" name="crButton" value="<c:out value="${chgRequest.crChangeRequestID}"/>" <c:if test="${status.first}">checked</c:if> />
                        </td>
                    </tr>
    </c:forEach>This produces no data, no rows. I don't get it. I can't find anything in my JSTL book that helps. Thanks.
    Ken

    Ignore the previous reply
    change it to the following
    <c:forEach var="chgRequest" items="${changeRequests}">
                    <tr>
                        <td>
                            <input type="radio" name="crButton" value="<c:out value="${chgRequest.crChangeRequestID}"/>" <c:if test="${status.first}">checked</c:if> />
                        </td>
                    </tr>
    </c:forEach>

  • Help -- How do I exit a Foreach Loop

    I have a foreach loop that is processing files in a directory.  One of the tasks is the execute sql task that calls a stored proc.  If this stored proc returns a certain value then I need to exit the loop and not process any more files.  But I have been unable to figure out how to make this happen.
    Any help would be greatly appreciated.
    Thanks!
    GN

     GN wrote:
    I have a foreach loop that is processing files in a directory. One of the tasks is the execute sql task that calls a stored proc. If this stored proc returns a certain value then I need to exit the loop and not process any more files. But I have been unable to figure out how to make this happen.
    Any help would be greatly appreciated.
    Thanks!
    GN
    have you considered using the script task instead?

  • During Foreach read another foreach - PLZ HELP!

    Hi all powershell gurus out there.
    I have a foreach which opens a URL from URLListl.txt and doing a
    Measure-command on them. The result from Measure-command writes to event-log. 
    In another text file i have country list, like:
    USA
    Canada
    Brazil
    and so on....
    I want in write eventlogs Message to read from this Text file and write it with the Measure-command result in Message part of the eventlog.
    The below is my script which works fine but it creates two entries for each URL.
    function Measure-Site
    $URLListFile = "C:\yourname\URLList.txt"
    $URLList = Get-Content $URLListFile -ErrorAction SilentlyContinue
    Foreach ($Uri in $URLList)
    $Time = Measure-Command {
    C:\yourname\MainScript.ps1}
    $Time.TotalSeconds
    $countrycode = (Get-Content c:\yourname\URLListcountry.txt)
    foreach ($SiteCode in $CountryCode)
    $LogFileExist = Get-EventLog -list | Where-Object { $_.LogDisplayName -eq "Scriptcheck" }
    if (! $LogFileExist)
    New-EventLog -LogName "Scriptcheck" -Source "Scripts"
    if ($Time.Totalseconds -lt 25)
    Write-EventLog -LogName "Scriptcheck" -Source "Scripts" -EntryType information -EventId 100 -Message " $SiteCode `nTotal Time: $Time"
    elseif ($Time.Totalseconds -gt 25)
    Write-EventLog -LogName "Scriptcheck" -Source "Scripts" -EntryType warning -EventId 101 -Message " $SiteCode `nTotal Time: $Time"
    if (Get-Process -name iexplore -ErrorAction SilentlyContinue)
    Stop-Process -Name iexplore
    Measure-Site

    Hi Arash,
    I’m writing to just check in to see if the suggestions were helpful. If you need further help, please feel free to reply this post directly so we will be notified to follow it up.
    If you have any feedback on our support, please click here.
    Best Regards,
    Anna Wang
    TechNet Community Support

  • Foreach loop help

    I am trying to create a foreach loop that takes all txt files in Program Files and print only the names of files over 10KB.
    This is what I got:
    foreach($file in (Get-ChildItem -Path "c:\Program Files" -recurse -Include *.txt |
    Select-Object FullName ))
    if($file.size -gt 10KB)
    Write-Host $file
    I've been testing around with this for a bit now and doing some Googling to no avail, it'll work if I don't try to sort it by size and ask it just to print the name of all text files in Program Files. Any nudge in the right direction would be appreciated.

    Let me be more explicit.  Whatou posted is not a loop.
    Always start with HELP when you are learning.  Ask your teacher to explain to you how to use HELP.
    help foreach.
    A ForEach loop cannot solve your issue here. You need to filter the results of a recursive search. In PowerShell this is almost never done with a loop. If your teacher tries to tell you otherwise you need to fire the teacher or take your money to a different
    school.
    Of course it may be more likly that you just didn't pay attention in class and are now asking us to do your homework for you.
    Sorry.  We don't do homework for children. This is a site for technicians who use scripting professionally. If you want to be a professional you need to do your homework No cheating. We are watching.
    ¯\_(ツ)_/¯

  • Need help with nested loop (c:forEach) tags. Can I break from inner loop?

    Hi all, I have this annoying problem and I am looking for any suggestions.
    I have 2 select boxes. One is for all available users, and second - for selected users (designated as admins). The list of all users is available in a collection (2 properties userId and userName displayed in the code below). The list of admins contains only userId (as strings).
    I have no problem with populating selected users (admins) list, reusing pretty much the same logic below, but I cannot find a way to break out from the nested loop once the match is found, to avoid repetitions leading to incorrect display of results.
    <select name=available>
    <c:forEach items="${users}" var="user" varStatus="outer">
        <c:forEach items="${adminIds}" var="adminId" varStatus="inner">
            <c:if test="${user.userId!=adminId">
                 <option value="<c:out value="${user.userId}" />"><c:out value="${user.userFullName}"/></option>
            </c:if>
        </c:forEach>
    </c:forEach>
    </select>
    <select name=selected>
    <c:forEach items="${users}" var="user" varStatus="outer">
        <c:forEach items="${adminIds}" var="adminId" varStatus="inner">
            <c:if test="${user.userId==adminId">
                 <option value="<c:out value="${user.userId}" />"><c:out value="${user.userFullName}"/></option>
            </c:if>
        </c:forEach>
    </c:forEach>
    </select>Can anyone help, please? I am also restricted to JSP 1.2

    Double post: http://forum.java.sun.com/thread.jspa?threadID=707950&tstart=0

  • Help with if/else in displaying data - (possibly foreach)

    Hello all,
    I've been trying to set something up, and I'm having difficulty getting it to work.
    Lines 84-111 have become my biggest difficulty.  I've got an if/else statement set up so that if one record has an image located on the localhost that image is pulled up.  The way I have it now, this works great.
    If I swap lines 93-96 with 102-105, and just tweek line 90, I can get it to work if the image is located on an alias and not the localhost.
    The problem is that if I have it like it is now, I can't get both to work at the same time.  So, I'm trying to get the if/else statement to apply to each record that is being pulled up.  It seems like what it is doing now is choosing which part of the if/else statement it needs to use for the first record, and then applies that for all records.
    Is there a way to have it coded like it is now for the if/else statement (because I want to be able to add multiple alias' and just check to see if the image is on the localhost or not); but have the image be displayed no matter if the image is located on the localhost or an alias?
    The following is what I've got so far:
    <?php
    $search = $_GET['series'];
    $query_begin=" SELECT * FROM movies WHERE movie_name_series = '$search' ";
    $search_begin = mysql_query($query_begin) or die(mysql_error());
    $row_begin = mysql_fetch_assoc($search_begin);
    if($row_begin == 0){
    ?>
    <script type="text/javascript"><!--
    setTimeout('Redirect()',0000);
    function Redirect()
      location.href = 'index.php?content=noresult';
    // --></script>
    <?php
    else
                    $query_display = "SELECT * from series WHERE series_id = '$search'";
           $result_display = mysql_query($query_display);
           $row_display = mysql_fetch_array($result_display, MYSQL_ASSOC);
              $series_id = $row_diaplay['series_id'];
              $series_name = $row_display['series_name'];
        ?>
    <h2>All Movies in our Library categorized in the series <?php echo $series_name ?></h2>
    <br />
    <div style="float: left; width: auto">
        Click on the name of the movie to edit the movie.
    </div>
         <br />
            <hr size="1" noshade="noshade" />
      <br />
    <?php
    $query="SELECT * FROM movies
      INNER JOIN family_rating ON movies.movie_star_rating=family_rating.star_id
      INNER JOIN alias ON movies.alias=alias.alias_id
      INNER JOIN parent_alert ON movies.parent_alert=parent_alert.alert_id
      INNER JOIN rating ON movies.movie_rating=rating.rating_id
      WHERE movies.movie_name_series='$search'
      ORDER BY movies.movie_name ASC";
    $result= mysql_query($query)or die (mysql_error());
    while($row=mysql_fetch_array($result)){
    // Display the data
    ?>
        <table width="200" style="margin: 20px">
        <tr align="center">
      <td valign="top">
       <h1 style="font-size: 12px"><?php echo $row['movie_name']; ?></h1>
            </td>
        </tr>
        <tr align="center">
      <td valign="top" style="width: 100%; border-bottom: ridge #FFF; border-left: ridge #FFF; background: url(assets/images/transback.png) repeat; padding: 10px">
       <a class="ToolText" onMouseOver="javascript:this.className='ToolTextHover'" onMouseOut="javascript:this.className='ToolText'">
       <style media="screen" type="text/css">
              #coverart {
                display: block;
                width: 110px;
                height: 150px;
              #coverart:hover {
                background: url("assets/icons/play_movie.png") no-repeat 0 0;
              background-size: 110px;
             </style>
            <p>
             <form action="index.php?content=play_movie" method="post">
                <input type="hidden" value="<?php echo $row['movie_id']; ?>" name="movie" />
             <input type="hidden" value="<?php echo $row['warning'] ?>" name="warning" />
                                        <?php
              if ($row['alias_name']='localhost') {
             ?>
                                        <input onmouseover='this.src="assets/icons/play_movie.png"'
                                         onmouseout='this.src="movies/coverart/<?php echo $row['art']; ?>"'
                                        type="image" src="movies/coverart/<?php echo $row['art']; ?>"
                                        style="border: none" height="150" width="110" />
                                        <?php
              }else{
               ?>
                                        <input onmouseover='this.src="assets/icons/play_movie.png"'
                                         onmouseout='this.src="http://<?php echo $row['ip_address']; ?>/<?php echo $row['alias_name']; ?>/coverart/<?php echo $row['art']; ?>"'
             type="image" src="http://<?php echo $row['ip_address']; ?>/<?php echo $row['alias_name']; ?>/coverart/<?php echo $row['art']; ?>"
                                        style="border: none" height="150" width="110" />
                                        <?php
              ?>
                </form>
                                        </p>
                                    <span><h2 align="center"><?php echo $row['movie_name']; ?></h2>
            <?php echo $row['rating_name']; ?>
                                    <h4><?php echo $row['description']; ?></h4>
            <?php
             if($row['parent_alert']='1') {
              ?>
            <p align"center"><img src="assets/icons/<?php echo $row['alert_file_name']; ?>"></p></span>
                                    <?php
             } else {
             ?>
                </a>
                <img src="assets/icons/s_<?php echo $row['star_file_name']; ?>" />
            </td>
    </tr>
        </table>
    <?
    ?>
    I've looked through a number of tutorials and it's been indicated to use a for each loop.  However, I can't seem to get this to work.  Is there anything I can do to get this to work the way I am trying to?  Is it a problem with my if/else or do I need a for each?  If I need a for each, how do I do that?
    Thanks.

    Thank you for your reply.  I apologize for not being as clear as I needed to be, so I'll try and explain better.
    I've got a page that pulls up some records from a database, where I've got an if / else statement as part of the section where it displays the data.
                                        <?php
              if ($row['alias_name']='localhost') {
             ?>
                                        <input onmouseover='this.src="assets/icons/play_movie.png"'
                                         onmouseout='this.src="movies/coverart/<?php echo $row['art']; ?>"'
                                        type="image" src="movies/coverart/<?php echo $row['art']; ?>"
                                        style="border: none" height="150" width="110" />
                                        <?php
              }else{
               ?>
                                        <input onmouseover='this.src="assets/icons/play_movie.png"'
                                         onmouseout='this.src="http://<?php echo $row['ip_address']; ?>/<?php echo $row['alias_name']; ?>/coverart/<?php echo $row['art']; ?>"'
             type="image" src="http://<?php echo $row['ip_address']; ?>/<?php echo $row['alias_name']; ?>/coverart/<?php echo $row['art']; ?>"
                                        style="border: none" height="150" width="110" />
                                        <?php
              ?>
    When the records are pulled, it seems like only the first part of the if / else statement is being applied to every record that is being pulled. The problem is if I've got records like the following:
    Record one - (file on the host computer)
    needs to be displayed from the condition
    src="movies/coverart/<?php echo $row['art']; ?>"
    Record two - (file on networked external hard drive)
    needs to be displayed from the condition
    src="http://<?php echo $row['ip_address']; ?>/<?php echo $row['alias_name']; ?>/coverart/<?php echo $row['art']; ?>
    The way it's coded now, only record one will display the image (record two will not display the image).  If I swap the order of the conditions, only record two will display the image (record one will not display the image).
    How do I get both record one and record two to display the image when both appear on the same page from a single search query?
    If I still did not explain it well enough, please let me know and I will try and do better.  Again, thank you for your help.

  • Help with c:forEach Tag (it is driving me insane)

    I keep getting this error (Don't know how to iterate over supplied "items" in <forEach>) whenever i run my jsp page.
    JSP Code:
    <c:set var="page_action" value="${sessionScope.httpData.find_Fix}" />
                        <c:set var="LoadedUpdates" value="${sessionScope.hotFix.fixDetails}" />
                        <c:if test="${page_action != null}" >
                            <div class="hot-fix">
                                <table>
                                    <c:forEach items="${LoadedUpdates}" var="updates" varStatus="status">
                                        <tr>
                                        <td> ${status.count} </td><td><c:out  value="${updates}" /></td>
                                        </tr>
                                    </c:forEach>
                               </table>
                            </div>
                        </c:if>
    JAVA Code (Backend Bean):
    import com.sun.java.util.collections.ArrayList;
    public class HotFixLoader {  
        ArrayList fixdetails = new ArrayList();
         public HotFixLoader(){
         for (int i = 0; i < 10; i++){       
                fixdetails.add("<a href=\"#\">xxxxxx</a>, xx/xx/xxxx, xyxyxyxyxy");
        public ArrayList getFixDetails(){      
            return fixdetails;
    }

    Double post: http://forum.java.sun.com/thread.jspa?threadID=720677&messageID=4158495#4158495

  • Help with forEach loop

    I have a JSTL forEach loop similar to below:
    <c:forEach var="product" items="${sessionScope.products}">
         <tr><td>${product.description}</td></tr>
    </c:forEach>I would like to use a static class to format the description. Something like below, but I know I cannot do it this way. How can I accomplish this?
    <tr><td>${ProductFormatter.getHtmlDescription(product)}</td></tr>thanks

    The least change approach. If you have already have a static function to do this, then a function tag would be appropriate.
    The function tag basically lets you call a static function from EL.
    custom.tld
    <?xml version="1.0" encoding="UTF-8" ?>
    <taglib xsi:schemaLocation="http://java.sun.com/xml/ns/javaee web-
            jsptaglibrary_2_1.xsd" xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.1"
    >
         <tlib-version>1.0</tlib-version>
         <short-name>my</short-name>
         <uri>http://www.mytags.com/</uri>
         <function>
              <name>productFormatter</name>
              <function-class>com.mypackage.ProductFormatter</function-class>
              <function-signature>java.lang.String getHtmlDescription(com.mypackage.Product)</function-signature>
         </function>     
    </taglib>If you include that tld in your WEB-INF directory, then the following in a JSP should work:
    <%@ taglib uri="http://www.mytags.com/" prefix="my"%>
    <c:forEach var="product" items="${sessionScope.products}">
         <tr><td>${my:productFormatter(product)}</td></tr>
    </c:forEach>Rather than putting the code in a static function, you might be better off encoding the logic into a custom tag. It depends on what your formatting function is like.
    cheers,
    evnafets

  • Help me    how to express    nested " c:forEach " tag content

    my jsp coutent :
    <%
    Collection topInfo=currentClass1.getTop12Info();
    Iterator itInfo=topInfo.iterator();     
    for(int j=0;j<3;j++) //������������3��
    %>
    <tr>
         <%
         for(int i=0;i<4;i++) //��������4��
              Info currentInfo=(Info) itInfo.next();
         %>
    <td width="25%" valign="top" bgcolor="#FFFFFF" style="border:#cccccc 1px solid">
    <%=currentInfo.getTitle()%>
    </td>
         <%
         if(!itInfo.hasNext()) break;
         %>
    </tr>
    <%}%>
    i express jsp coutent above ! but it's error hava repeat cells
    <c:forEach begin="1" end="3"><!-- ������������3�� -->
    <tr>
         <!--//��������4�� -->
    <c:forEach var="currentInfo" items="<%=currentClass1.getTop12Info()%>" begin="1" end="4">
    <td width="25%" valign="top" bgcolor="#FFFFFF" style="border:#cccccc 1px solid">
    <font color="#CC0000">${currentInfo.title}</font></a></strong>
         </td>
    </c:forEach>
    </tr>
    </c:forEach>

    <c:forEach begin="1" end="3"> <!-- every type of info show 3 row-->
    <tr>
    <!-- ervery row show 3 cell-->
    <c:forEach var="currentInfo" items="<%=currentClass1.getTop12Info()%>" begin="1" end="4">
    <td width="25%" valign="top" bgcolor="#FFFFFF" style="border:#cccccc 1px solid">
    <font color="#CC0000">${currentInfo.title}</font></a></strong>
    </td>
    </c:forEach>
    </tr>
    </c:forEach>
    I hope you can test this code as above , you see the result ,you can understand the problem,the result is different from result of script[b                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Maybe you are looking for

  • File adapter OS command line - Calling a command remotely ??

    Hi, We have a scenario where in which receiver file adapter after putting a file on the FTP  , a subsequent XML loader needs to be called which would load data into the client legacy ERP system. There seems to be some idea about doing it through file

  • ITunes will not launch after upgrade--click, bounce bounce, nada

    iTunes will not launch after upgrade--rebooted nothing--2 bounce icon then shut down all and unplugged, restarted--no change, iTunes still will not launch after upgrade iTunes current version on imac w/10.6.8

  • How to convert raw to number in oracle 8

    Does anyone know how to convert a raw data to number format ??? If i do: select dump(50,16) from dual, it will return bytes c1 33. With this bytes in a raw variable, how can i convert it to a number variable in Oracle 8. PS: Oracle 8 doesn't have utl

  • Multiple BP relationships

    Hi gurus, I need help on the foll issue - We are on SRM 5.0  having HR replication from ECC 6.0. Recently  few users changed position. When these were replicated from back end, an additional 'Is Employee of ' relationship was created for new org unit

  • I can't join meeting

    Hi, I am getting this error message when I try and  join a meeting (this is after I have input the meeting ID and entry code given to me by the host): Live meeting cannot connect to the meeting. Try again in a few minutes. If you still can't connect