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?

Similar Messages

  • Problem using ViewObject with bc4j:table

    Hello !!
    This is the query of my ViewObject:
    select * from speiseplan order by jahr desc, kw desc;
    and everything works fine in the BC4J tester:
    jahr kw
    2003 52
    2003 7
    2003 3
    2002 51
    But in my uix page the rows are not correctly sorted:
    jahr kw
    2003 3
    2003 7
    2003 52
    2002 51
    What's going wrong here?
    Thanks for your help.
    Regards,
    Mareike

    Duplicate post.
    Original problem using ViewObject with <bc4j:table>

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

  • Use var of sql:query tag into a jsp fragment code

    Hi, i'm spanish and my english is not very good XD.
    I need to use some data from <sql:query> tag into code jsp <% %>
    EXAMPLE:
    <sql:query var="variable">
    </sql:query>
    <% what can i do to access to "variable" here????????? %>
    i need to save in session (session.setAttribute(...)) a field of the response of the query saved in "variable"
    i need help!!!!, thanks!!!!!!!!

    i need to save in session (session.setAttribute(...)) a field of the response of the query saved in "variable"Why do you need java code to do this? If you are using JSTL sql tags, then why not keep using JSTL tags?
    <c:set var="valueToSave" value="${variable.field}" scope="session"/>EL variables are actually already stored as attributes in scope.
    So to get hold of "variable" you could use <%= pageContext.findAttribute("variable") %>
    and that would give you the object stored by the EL.
    cheers,
    evnafets

  • How to use rowspan with display:column tag

    Folks,
    For displaying table in my project I am using display:table tag. Now in one of the column i need to use row span attribute. How can i use that.
    Waiting for the reply.

    i dont think u can set a rowspan in display:table !!!!

  • 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

  • How to numberformat when using sql:query alogn with c:forEach JSTL tags

    Is there anyway to format the numeric values returned from the database when using <sql:query> alogn with <c:forEach> tags
    Here is my jsp code
    <sql:query..../>
    <c:forEach var="row" items="${queryResults.rows}">
    <tr>
    <td><c:out value="${row.COL1}" /></td>
    <td><c:out value="${row.COL2}" /></td>
    </tr>
    </c:forEach>
    Col1 values are numeric without any formats Eg: 1000, 10000, 1000000 etc.
    how can i format them to 1,000 , 10,1000 , 100,000 etc

    It is polite to mention what your answer was. These posts are not just here for you to ask questions, but to be used as a resource for other people to find answers. Saying "I solved it" with no details helps noone.
    I presume you discovered the JSTL <fmt:formatNumber> tag?

  • 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 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.

  • 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!

  • Using Content Query webpart for specific Document library with multiple managed metadata - Document with multiple metadata tags not showing up

    Hi,
    I am having an issue where when I insert a Content Query webpart into a page, and filter to managed metadata, all the right documents show up except one document that happens to have two metadata tags attached to it.  The content query webpart is set
    to only look through a specific document library.  I'm not sure what I am doing wrong.
    Here is the one document with two metadata tags:
    Below is the Content Query:

    Hi,
    As I understand, you did not get the results with multiple metadata tags through Content Query web part in SharePoint 2013.
    Check things below:
    1. Check if you have set the item limit more than the display items in Presentation section of the web part. If the item number more than item limit, the rest items will not show.
    2. Check if the item you cannot find uses the content type you have set in the content type section of content query web part.
    When you edit the properties of the item, you will see the content type the item is using.
    Best regards
    Sara Fan
    TechNet Community Support

  • Re: Announce: J2EE MVC training using Struts with Standard Tags (JSTL)   8/2 in NYC

    Standard J2EE MVC training using Struts with Standard Tags (JSTL)
    -We have done more Struts training than anyone. This class adds Standard Tag Libs (JSTL) with MVC and a portal discussion.
    Full Syllabus is at :
    http://www.basebeans.com/syllabus.jsp
    NYC on 8/2.
    This is the last week to sign up :
    http://www.basebeans.com/classReservation.jsp
    More dates(tentative):
    8/9 - Chicago downtown Marriott
    8/16 - Atlanta downtown Marriott
    8/23 - Austin downtown Marriott
    To keep up on upcoming MVC training sign up at:
    http://www.basebeans.com:8081/mailman/listinfo/mvc-programmers
    Hope to see you,
    Thanks,
    Vic
    Ps. 1: Set your newsreader such as Outlook Express or Netscape to news.basebeans.com for Open Standard news groups like JDO, Apache, SOAP, etc.
    Ps 2: The sample app will be available end of next week at:
    http://www.basebeans.com/downloads.jsp

    i have same problem with
    CLI130 Could not create domain, domain1
    then i try these things with PATH stuff but it haven't worked for me...
    then i tried to search windows registry for string domain1 and nothing found...
    then i searched my profile directory (on windowsxp c:\Documents and Settings\user on linux /home/user) for files that containd string domain1 and i found some .adadmin* files (as i remember there were 3 files) then i deleted them, try to install sun app server and it works for me... there are still some warnings but at least installation finishes and files were not deleted...
    i hope this help...
    for me it does

  • Spec oversight? Using dynamic-attributes in XML tag files

    I have a couple of tagfiles that generate form elements with specific conventions for the 'name' and 'value' attribute. Basically, a data binding framework.
    Dynamic attributes are useful because you can delegate all the usual html attributes to the generated HTML form element: SELECT, INPUT, id, class etc.
    The usual way to do this is to concatenate all the "pass-through" attributes to a string, and append this string to the element generated:
    <input type="hidden" name="foo" ${dynattrs}/>I'm wondering how to do this in a tagfile in XML format (mytag.tagx), since the XML format forbids syntax like in the example above.
    jsp:attribute won't help much, if it's nested inside a c:forEach: it won't apply to the right element.

    Ran into the same problem with 'optional attributes'. (see post "JSP 2.0 Tag files outputting elements with conditional attributes" http://forum.java.sun.com/thread.jspa?forumID=45&threadID=681033)
    Found a solution that is not very elegant but does work and saves you the trouble of reverting to Java Tags. Consider the following tag-file that outputs an html input-tag with conditional attributes:
    <?xml version="1.0" encoding="utf-8"?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2"
         xmlns:c="http://java.sun.com/jsp/jstl/core">
         <jsp:directive.attribute name="name" required="true" type="java.lang.String"/>
         <jsp:directive.attribute name="id" required="false" type="java.lang.String"/>
         <jsp:directive.attribute name="value" required="false" type="java.lang.String"/>
         <jsp:directive.attribute name="disabled" required="false" type="java.lang.Boolean"/>
         <jsp:directive.attribute name="hint" required="false" type="java.lang.String"/>
         <jsp:directive.attribute name="cssClass" required="false" type="java.lang.String"/>
         <jsp:text><![CDATA[<input type="text" name="]]><c:out value="${name}"/><![CDATA["]]></jsp:text>
         <c:if test="${!empty id}"><![CDATA[ id="]]><c:out value="${id}"/><![CDATA["]]></c:if>
         <c:if test="${!empty cssClass}"><![CDATA[ class="]]><c:out value="${disabled?(cssClass + '-disabled'):cssClass}"/><![CDATA["]]></c:if>
         <c:if test="${disabled}"><![CDATA[ disabled="disabled"]]></c:if>
         <c:choose>
              <c:when test="${!empty value}"><![CDATA[ value="]]><c:out value="${value}"/><![CDATA["]]></c:when>
              <c:when test="${!empty hint}"><![CDATA[ value="]]><c:out value="${hint}"/><![CDATA[" onfocus="if(this.value==']]><c:out value="${hint}"/><![CDATA[')this.value='';"]]></c:when>
         </c:choose>
         <jsp:text><![CDATA[/>]]></jsp:text>
    </jsp:root>In answer to your question: Yes, it looks like an oversight. Using the jsp:attribute tag in a c:forEach doesn't work because the attribute is then applied to the forEach tag. You would have to put the attribute-tag inside a jsp:body tag (inside the forEach). Then it would apply not to the forEach tag but to the tag enclosing the forEach. However, this doesn't work either, or at least it doesn't work in Tomcat 5.5. Could be a bug though, JSP 2.0 is still very buggy (for instance, using a tagfile inside another tagfile from the same taglib doesn't seem to work either...)
    Anyway, if you ever find a good solution please let me know by posting to this topic!
    TIA

  • 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

Maybe you are looking for

  • USB to SPI

    Hi Can we read USB device using Labview 8. Our application can be better explain with the help of attached block diagram. Please find the attached Document. In this application , we are using a sensor having SPI interface.Then with the help of Nation

  • SQL Server Database Problems

    I have been using SQL Server for sometime with my company's product with no unusual problems for some time. However, having recently installed a Forte repository on a newly setup NT machine (Workstation 4, SP4), I have come across problems. The code

  • How to Kill Links?

    Recently, two PDF files, created by Export from Pages have apparently triggered the SPAM filters of large network recipients. The content of these PDF originated with material on web pages, which contained some live links. The links remain live, and

  • My Google Toolbar is not showing and should be

    When I brought up Firefox yesterday I had no Google Toolbar. According to troubleshooting, it should be showing and is not.

  • Photoshop CS5.1 VDCAssistant

    Hello, I've been using the Photoshop CS5.1 trial for a while now and I noticed that Photoshop always seems to open an instance of the VDCAssistant process.  This process is used to get images from the iSight webcam (Photo Booth, e.g., or a video chat