C:forEach tag giving bad times

hi there,
i have 4 combo boxes, each one depending on the next one.
The first is COUNTRY once you've selected the country, STATE will be populated, then COUNTY and then CITY.
all the informations must be retrieved querying a database.
i'm having hard times with this but i'm trying to do it in the most easily way i can find.
actually i am able to populate the country box and this works fine, then i'm trying to trigger an onChange event on the country box to pass the value of the selected option to a javascript that will take care of the next step.
here is the code:
JSP page
<select name="nazione" onChange="javascript:pescaRegioni(this.value)">
     <option value=""> -- Nazione --
     <c:forEach items="${requestScope.nazioni}" var="country">
     <option value="<c:out value='country'/>"> <c:out value='${country}'/>
     </c:forEach>
     </select>
JAVASCRIPT
function pescaRegioni(country)
     alert(country);
     location.href="PopulateBoxes?nazione="+country+"&regione=&azione=inserisci";
}i put the alert in the javascript just to check the value of country and whether i check France or Italy or whatever the value i get is "country".
i know this is because the var country defined in the for each tag is invisible outside the tag.
i also tryed this.[this.selectedIndex].value but it's obvious that is the same thing of this.value and that it won't solve the nested visibility problem at all any way.
moreover even if a c:out could help (it won't), i cannot put it in the onChange event because i'm using a javascript there.
please help!!
thanks in advance

double post http://forum.java.sun.com/thread.jspa?messageID=4063433
ram.

Similar Messages

  • JSTL forEach tag taking longer time than scriplets ???

    Hi Gurus,
    My STRUTS action class setsup a collection object [roughly 900 + records stored as java beans] to be displayed on my view [JSP]. The problem is, when I iterate over this collection in JSP using <c:forEach> tag, it takes around 4-5 minutes to build up the page.
    I coded the same looping logic through java scriplets embedded within JSP and the processing came down to 1 minute. Should I assume that <c:forEach> tag will have a processing overhead over plain java code in JSP?
    FYI, I checked the server generated SERVLET code under WORK directory of TOMCAT for this JSP with <c:forEach> tag and find lot of code being generated for this <c:forEach> tag implementation. Could it be that the processing of these generated code takes longer than plain java using scriplets?
    Please Help.
    Thanks,
    Karthik.
    <b>JSP using <c:forEach></b>
    <c:forEach var="refurb" items="${BOMDataForm.refurbSummary}" varStatus="loopStatus">                    
    <tr valign="top" bgcolor="#FFFFFF"> 
    <td>
    <div align="center"><span class="modulecontent"><c:out value="${refurb.configName}" /></span></div>
    </td>                     
    <td>
    <div align="center"><span class="modulecontent"><c:out value="${refurb.itemName}" /></span></div>
    </td>
    </tr>
    </c:forEach><b>JSP using embedded scriplets</b>
    <%
    BOMDataForm bomDataForm = (BOMDataForm) request.getAttribute("BOMDataForm");
    ArrayList arrayList = (ArrayList) bomDataForm.getRefurbSummary();
    int loop = arrayList.size();
    for (int i=0;i<loop;i++) {
    out.println("<tr valign=\"top\" bgcolor=\"#FFFFFF\">");
    out.println("<td>");
    out.println("<div align=\"center\"><span class=\"modulecontent\">");
    out.println(((RefurbSearchResult)arrayList.get(i)).getConfigName());
    out.println("</span></div>");
    out.println("</td>");
    out.println("<td>");
    out.println("<div align=\"center\"><span class=\"modulecontent\">");
    out.println(((RefurbSearchResult)arrayList.get(i)).getItemName());
    out.println("</span></div>");
    out.println("</td>");
    out.println("</tr>");                         
    %>

    Never looked at the speed issues. For me it has always been "fast enough"
    When displaying pages with 900 records on it the common approach is to split the result across multiple pages, so that loading doesn't get too long.
    The JSTL tags obviously introduce some overhead in extra procedure calling. As you found out by looking at the generated servlet code.
    Also the EL expressions have to be evaluated. using the reflection APIs. Its pretty certain that direct access to the object is faster.
    The forEach tag uses an iterator under the hood, where you are calling get(i) directly on an ArrayList.
    Any or all of these would be contributing. My guess would be the EL expression evaluation is probably the most overhead.
    One thing about your example I would like to see is how long it would take using an Iterator, rather than calling get(i) on the array elements. That would remove at least one of the differences.
    So in short, yes the JSTL is adding overhead to your page. I'm a bit surprised to hear it is so much though.
    Cheers,
    evnafets

  • Using ViewObject with a foreach tag in a jsp

    Hi guys I have the following scenario:
    1- I call a certain .jsp page
    2- a controller class (extends servlet) is called, this class: takes a view object, executes it's query, forwards the result to the jsp page.
    3- jsp page has a foreach tag that iterates over the query result.
    My problem is that foreach tag only takes list or array in its "items" attribute.
    Now is there a way to put the view object result in an array/list? in other words in my servlet what should I put in the request so that the foreach tag can iterate over the rows of the query. Thank you in advance for the reply.

    Thank you for the reply.
    But my application is not a web based one.
    I am developing a framework (as swf) in which some other swf files (target files) are played as movie clip. Since the framework swf should be considered as a general one, no direct linking to the other swfs preferred. I follow some (my own) rules to get things worked. For example, I need to show a simple movie cilp as the title in the framework. This movie clip will be different in different target swfs, and they will be stored inside the target swfs itself. I was thinking about giving them a unique id (eg. title_id) and after loading the target swfs, show their titles (movie clips) in one of the framework's empty movie clip (using attachMovie).
    Could please suggest me any idea to get things work?

  • How can I activate multiple tags at one time?

    How can I activate multiple tags at one time?

    I'm pretty sure you can run this on a sub tree of /etc/tags
    http://dev.day.com/docs/en/cq/current/wcm/page_publish/tree_activate.html

  • Using a viewobject with foreach tag in .jsp

    Hi guys I have the following scenario:
    1- I call a certain .jsp page
    2- a controller class (extends servlet) is called, this class: takes a view object (let's call it view), executes it's query, forwards the result to the jsp page.
    3- jsp page has a foreach tag that iterates over the query result.
    My problem is that foreach tag only takes list or array in its "items" attribute.
    Now is there a way to put the view object result in an array/list? in other words in my servlet what should I put in the request so that the foreach tag can iterate over the rows of the query. Thank you in advance for the reply.

    This code works fine for me:
    <%@ taglib uri="/jstl-c" prefix="c" %>
    <html>
         <body>
         <%
              int array[] = new int[] {1,2};
              session.setAttribute("array", array);
              String arrayNames[] = new String[]{"One", "Two"};
              session.setAttribute("arrayNames", arrayNames);
         %>
              <form action="?">
              <select name="select">
                   <c:forEach items='${ sessionScope.array}' var="row">
                        <c:choose>  
                             <c:when test="${param.select== row}"> >
                                  <option value="<c:out value='${row}'/>" selected><c:out value="${sessionScope.arrayNames[row-1]}"/></option>
                             </c:when>   
                             <c:otherwise>
                                  <option value="<c:out value='${row}'/>"><c:out value="${sessionScope.arrayNames[row-1]}"/></option>
                             </c:otherwise>
                        </c:choose>
                   </c:forEach>
              </select>
              <input type="submit" name="submit" value="submit"></input>
              </form>
         </body>
    </html>
    good luck.
    MatrixPooh
    www.bizdisplay.com

  • How use forEach tag in xml tag library

    Hi,
    Can u please explain the procedure for using forEach tag for displaying the parsed xml tags?
    This is the code snippet
    <%@ page contentType="text/html" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml" %>
    <html>
    <body>
         <c:import url="\books.xml" var="url" />
         <x:parse xml="${url}" var="doc" />
              <x:forEach var="n" select="${doc}/books/book">
                   <x:out select="${n}/title"/>
                   <x:out select="${n}/author" />
         </x:forEach>
    </body>
    </html>
    but I got the fallowing error.
    java.lang.NoClassDefFoundError: org/saxpath/SAXPathException
         at org.apache.taglibs.standard.tag.common.xml.ForEachTag.prepare(ForEachTag.java:51)
         at javax.servlet.jsp.jstl.core.LoopTagSupport.doStartTag(LoopTagSupport.java:262)
         at jsp_servlet.__index._jspService(__index.java:197)
         at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
         at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:971)
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:402)
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6350)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
         at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3635)
         at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)

    Just the same way as you do in JSP. Since JSF 1.2 you can use unified EL #{ } in c:forEach.
    You can also use Tomahawk's [t:dataList|http://myfaces.apache.org/tomahawk-project/tomahawk12/tagdoc/t_dataList.html] by the way. It is more efficient.

  • c:forEach tag

    Hi,
    I'm trying to use the forEach tag in the jstl in order to display the contents of an Hashtable. The table is written in the session and arrives populated with the results of a SELECT query.
    The elements of the table are instances of a class of mine, and I'd like to display some of the fields (all accessible by getters and setters) of this class.
    The fact is that if I try to write the elements of the table, I obviously get the class of the elements followed by their ID number (like Object@64383265), but if I try to access a field, I get nothing.
    Here is the code reading the elements:
    risposta = Hashtable in the session, contains dap.obj.Notizia objects
    <jsp:useBean id="notizia" scope="page" class="dap.obj.Notizia" />
    <c:forEach var="notizia" items="${risposta}">
         <c:out value="${notizia}" />
    </c:forEach>
    And if I try to replace the line of output with:
         <c:out value="${notizia.ID}" />
    I obtain an error saying:
    (...) Unable to find a value for "ID" in object of class "java.util.Hashtable$Entry" using operator "." (null)
    If I use
         <c:out value="${notizia.[ID]}" />
    no errors and nothing appears..
    Do I need to know something about the cast inside the tags of jstl or am I trying to do something wrong?
    I admit that these are my first days with jstl, but I've searched among some books with no results. Thanks in advantage for your jelp

    Seeing as you are accessing a Map, the object you get back is a Map.Entry
    So you can access it as ${notizia.key} to get the hash key, and ${notizia.value} to get the object of type Notizia
    <c:forEach var="notizia" items="${risposta}">
    <c:out value="${notizia.value.ID}" />
    </c:forEach>Cheers,
    evnafets

  • 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 %>'>

  • How To check in Ironport log which is server is giving bad response to SMTP connection?

    How To check in Ironport log which is server is giving bad response to SMTP connection?

    You probably want to create a new log subscription for "SMTP Logs"
    Go to System Administration/Log Subcriptions.
    Click Add Log Subscription
    Pick SMTP Conversation Logs.
    Pick a log name (will be the folder name that gets created for the log files)
    The defaults for the rest should be fine... maybe tweak rollover...
    Make sure to remove it after you're done, its going to eat space and probably a little proc... its VERY verbose, but it should show you what you need.

  • Foreach tag

    hello,
    I use a foreach tag to browse a map, but some ">" are add betwen two items. I would like to know why...
    here is my code:
    <c:forEach var="map" items ="${dependency.versions}">
              <c:set scope="session" var="project" value="${map.key}" />
              ${project.name} [${map.value}]  
    </c:forEach>
    here is the result:
              <
                   <a href="project6 [1.9.3]  
              <
                   <a href=" project4 [1.8.2]  
              <
                   <a href="project5 [1.9.2]  
              <
                   <a href="project7 [1.8.1]  
              <
                   <a href=" project1 [1.8.1]  
              <
                   <a href="project3 [1.9.1]  
              <
                   <a href=" project2 [1.8.1]  
    thank you for yours future responses
    Julien

    I'm not entirely sure wat u stored in "requestScope.cdo.intexDeal.tranches"; make sure every level follows the "getCdo()" "java.util.Collection" ... rules, try debug using varStatus
    <c:forEach var="z" items="${requestScope.cdo.intexDeal.tranches} " varStatus="tranches_status">
    <p>debug status: <c:out value="${tranches_status}"/></p>
    <p>debug var: <c:out value="${z}"/></p>
    </c:forEach>if it is not the object instance you are expecting, at least you'll know where the error occurs!
    do define more clearly on your solution u r trying to use ..., actually I don't quite get you.
    By Avatar Ng

  • In iPhoto 09 Info does not show tags on aperture, time, iso etc. Other tags like place, pixels are shown. There is no little arrow on this info menu to go to full info box. How come ?

    in iPhoto 09 Info does not show tags on aperture, time, iso etc. Other tags like place, pixels are shown. There is no little arrow on this info menu to go to full info box. How come ?

    It does. Photos Menu -> Show Extended Photo Information.
    Then note the disclosure arrows as indictaed in this thread:
    https://discussions.apple.com/message/16512794#16512794
    Regards
    TD

  • Getting current index of forEach tag

    How do you get the current index of the forEach tag, that is looping through a Vector?
    <c:forEach var="rows" items="${myRequestManager.solPORList}">

    Yes, use the varStatus attribute:
    <c:forEach items="${variables}" var="variable" varStatus="status">
       <c:out value="${status.index}"/>
       <c:out value="${status.count}"/>
    </c:forEach>status.index, the current index, starts with 0. status.count, a running count of loop iterations, starts with 1.
    Get a JSTL book. Shawn Bayern's "JSTL In Action" is the best, IMO. - MOD

  • JSTL : problems with sql:query /forEach  tag

    I am not able to iterate thru the resultset provided by <sql:query> tag in JSTL. rowcount and columnName works, which means that query does produce a resultset. However, the <c:forEach> tag doesnt display the retrieved data. Code is approx like:
    c:catch var="e">
    <sql:query var="queryResults" >
    select * from emp
    </sql:query>
    </c:catch>
    <c:if test="${e!=null}">The caught exception is: ${e}
    ${queryResults.rowCount} <br>
    <c:forEach var="row" items="${queryResults.rows}">
    <tr>
    <td> <c:out value="${row.EMPNO}" /></td>
    </tr>
    </c:forEach>
    </table>
    Error thrown is :
    javax.servlet.ServletException: Unable to find a value for "EMPNO" in object of class "java.lang.String" using operator "."
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800)
         org.apache.jsp.jsp.sql.query_jsp._jspService(query_jsp.java:92)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    Pls. help!

    Thanks a lot all. My problem was solved by simply replacing the taglib directive
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
    to
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    Cheers!

  • C:forEach tags

    Hi- I'm trying to use a c:forEach tag and am having some problems.
    Basically, I want to use an iterator that I get from a helper class to loop over, but I don't want to use EL (this is not a possibility at the moment). Is there any way to do this? Every example I've found uses EL, but there must be a solution that was used before EL was introduced... I hope...

    but there must be a solution that was used before EL was introduced... Sorry to disappoint you but EL was introduced hand in hand with the JSTL.
    What sort of server are you using?
    JSP2.0 container (eg Tomcat 5), use JSTL 1.1, and you can use <%= expr %> instead of ${expr} easily.
    In a JSP1.2 container, you have to use the JSTL1.0 "runtime" version of the taglib.
    <%@ taglib prefix="c-rt" uri="http://java.sun.com/jstl/core-rt"%>
    This taglib lets you use runtime expressions <%= expr %> with the JSTL tags in a JSP1.2 container.
    Good luck,
    evnafets

  • FOX CLOCKS not giving correct time. Central time is 2 hours ahead of the actual time

    FOX CLOCKS not giving correct time. Central time is 2 hours ahead of the actual time

    sorry not an Atomic clock issue I read your post wrong
    actually last night I tried to set my clock back to the time without Daylight savings and it would only let me set it to 1 or 3 am but not 2.. I noticed this, but I would wait till Sunday is over and see if this bug is only a one day issue which I have a feeling it may be, wait till 3am march 10th and see if this bug fixes itself I have a feeling it will

Maybe you are looking for

  • Help installing nvidia and X

    Hi new to Linux & Arch, having trouble running X, hoping someone could help! installed Arch no prob, followed wiki instructions for installing nvidia and then Xorg. When I try to start X I get "Failed to load the NVIDIA kernel module!" modprobe nvidi

  • F4 help for Code groups while creating a notification.

    Hi all, We are using Exit QQMA0015 to filter the code groups for object parts, Damage, Causes and Activities  based on the Z table. Our requirement is based on Object Parts, we want to restrict f4 help for Damage and then based on Object Parts and Da

  • Struts, Best proctices to show data from database in view

    Hi, I am using Struts. I need to show a result of select operation, some 50-60 records like a grid. Best method to transfer ResultSet data to View(jsp) from the Action's execute method. Is it a right way to use a collection of objects, that contains

  • Error message adobe reader 11

    adobe reader could not open tif file becuase it is either not a supported file type or because the file has been damaged. same error message recieved for adobe reader 9 & 11 please help

  • Clearing cache on OSX 10.7.5, Clearing cache on OSX 10.7.5

    I ccan't find the tools menu on myMBP to be able to clear the cache. Having problems with getting into a site.that I have updated seeral times as it is a wbsite I have developed. On previous versions there was atools item that could be clicked to se