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

Similar Messages

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

  • 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

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

  • Problem using jsp:include from inside a custom tag

    Hi, All !
              I have a problem using <jsp:include> from inside a custom tag. Exception is:
              "java.lang.ClassCastException: weblogic.servlet.jsp.BodyContentImpl"
              Apparently, weblogic tries to cast BodyContentImpl to JspWriterImpl and
              could not do this. Is it a bug, since in the 1.1 spec is said: "The
              BodyContent is a subclass of JspWriter that can be used to process body
              evaluations so they can retrieved later on."
              My code is:
              <wfmklist:items>
              <jsp:include page="item.jsp" flush="true"/>
              </wfmklist:items>
              

    This is an area of contention with WL. It is not so tolerant with regards to
              the spec. I spent several days recently trying to convince it to accept the
              specification in regards to bodies and includes and it appears to have
              successfully rebuffed my efforts.
              Frankly, this is very disappointing. It appears that some shortcuts were
              taken on the way to JSP 1.1 support, and the result is a very hard-coded,
              inflexible implementation. As I have not seen the implementation myself, I
              hate to assume this, however one could posit that the term "interface" was a
              foreign concept during the implementation, other than as some annoying
              intermediary reference requiring an immediate cast to a specific Weblogic
              class, which in turn is apparently required to be final or have many final
              methods, as if being optimized for a JDK 1.02 JIT.
              I am sorry that I don't have any positive suggestions other than to use a
              URL object to come back in an execute the necessary "include" directly. You
              lose all context (other than session) and that can cause its own problems.
              However, you can generally get the URL approach to work, and you will
              hopefully avoid further frustration.
              Peace,
              Cameron Purdy
              Tangosol, Inc.
              http://www.tangosol.com
              Tangosol: How Weblogic applications are customized
              "Denis" <[email protected]> wrote in message
              news:[email protected]...
              > Hi, All !
              > I have a problem using <jsp:include> from inside a custom tag. Exception
              is:
              > "java.lang.ClassCastException: weblogic.servlet.jsp.BodyContentImpl"
              >
              > Apparently, weblogic tries to cast BodyContentImpl to JspWriterImpl and
              > could not do this. Is it a bug, since in the 1.1 spec is said: "The
              > BodyContent is a subclass of JspWriter that can be used to process body
              > evaluations so they can retrieved later on."
              >
              > My code is:
              > ...
              > <wfmklist:items>
              > <jsp:include page="item.jsp" flush="true"/>
              > </wfmklist:items>
              > ...
              

  • Problem redering h:outputText tag on a jsp fragment

    Hello to all... I'm trying to understand and use this new technology and I have encountered a problem that I cannot find any documentation as how to solve it. First I have my welcome.jsp page that I am using to call my fragment:
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
    <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JSP Page</title>
        </head>
        <body>
            <f:view>
                <h1><h:outputText value="Java Server Faces" /></h1>
                <f:subview id="banner">
                    <c:import url="/banner.jsp"/>
                </f:subview>
            </f:view>
        </body>
    </html>then I have my jsp fragment, banner.jsp:
    <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
    <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
        <f:loadBundle basename="com.gm.gsip.messages" var="msgs"/>
        <table border="1">
            <tr>
                <td> <h:outputText value="#{msgs.hour}"/> � </td>
                <td> <h:outputText value="#{msgs.hour1}"/> �</td>
                <td> <h:outputText value="#{msgs.hour2}"/>� </td>
                <td> <h:outputText value="#{msgs.hour3}"/> �</td>
                <td> <h:outputText value="#{msgs.hour4}"/>� </td>
                <td> <h:outputText value="#{msgs.hour5}"/> �</td>
                <td> <h:outputText value="#{msgs.hour6}" /> �</td>
                <td> <h:outputText value="#{msgs.hour7}" /> �</td>
                <td> <h:outputText value="#{msgs.total}" />� </td>
            </tr>
        </table>My problem is that the <h:outputText> tag is rendering the values outside the table. This is what gets displayed:
    Java Server Faces
    Hour1234567TOTAL
    If I copy/paste the table tags (including the <h:outputText> tags) on the main jip, it renders without any problem:
    Java Server Faces
    Hour 1 2 3 4 5 6 7 TOTAL
    I'm guessing that I might be missing some other jsf tag inside the jsp fragment. Any help will be greatly appreciated.
    -thanks
    Rolando

    I can suggest you with the following solutions
    1. try having <%out.flush();%> before and after c:import
    2. try with jsp:include with flush=true
    Can you reply back with which one works? I didnt try out both of them
    Thanks

  • Sp9 / pre-release / problem with jsp tags

              WLS 5.1, sp9 pre-release, solaris 2.7, WLCS 3.2
              JSP compile fails with the exception...
              weblogic.servlet.jsp.JspException: (line -1): Error in tag library
              at: 'wl':
              The Tag class 'weblogicx.jsp.tags.CacheTag' has no setter method
              corresponding to
              TLD declared attribute 'async', (JSP 1.1 spec, 5.4.1)
              at weblogic.servlet.jsp.StandardTagLib.jspException(StandardTagLib.java:138)
              at weblogic.servlet.jsp.StandardTagLib.processTag(StandardTagLib.java:264)
              at weblogic.servlet.jsp.StandardTagLib.processTagElements(StandardTagLib.java:146)
              at weblogic.servlet.jsp.StandardTagLib.<init>(StandardTagLib.java:125)
              at weblogic.servlet.jsp.JspLexer.loadTagLib(JspLexer.java:95)
              at weblogic.servlet.jsp.JspLexer.mTAGLIB_DIRECTIVE_BODY(JspLexer.java:3873)
              at weblogic.servlet.jsp.JspLexer.mTAGLIB_DIRECTIVE(JspLexer.java:3623)
              at weblogic.servlet.jsp.JspLexer.mDIRECTIVE(JspLexer.java:3484)
              at weblogic.servlet.jsp.JspLexer.mSTANDARD_THING(JspLexer.java:1817)
              at weblogic.servlet.jsp.JspLexer.mTOKEN(JspLexer.java:1658)
              at weblogic.servlet.jsp.JspLexer.nextToken(JspLexer.java:1548)
              at weblogic.servlet.jsp.JspLexer.parse(JspLexer.java:888)
              at weblogic.servlet.jsp.JspParser.doit(JspParser.java:69)
              at weblogic.servlet.jsp.JspParser.parse(JspParser.java:125)
              at weblogic.servlet.jsp.Jsp2Java.outputs(Jsp2Java.java:109)
              at weblogic.utils.compiler.CodeGenerator.generate(CodeGenerator.java:242
              

              It could just be me - I an un-jarred a version of weblogic-tags-510.jar where WLS
              could find it.
              mike
              Kumar Allamraju <[email protected]> wrote:
              >Yes, my JSP is referring the tag libs. I 'm using counter example given
              >in
              >examples/jsp/tagext/counter directory
              >
              ><NT Performance Pack> NATIVE: created IoCompletionPort successfully.
              >I
              >oPort=0x000001d4
              >Sun Apr 01 12:44:00 PDT 2001:<I> <WebLogicServer> WebLogic Server star
              >ted
              >Sun Apr 01 12:44:40 PDT 2001:<I> <NT Performance Pack> Allocating: '2'
              > NT reader threads
              >Sun Apr 01 12:44:41 PDT 2001:<I> <ServletContext-General> *.jsp: init
              >Sun Apr 01 12:44:41 PDT 2001:<I> <ServletContext-General> *.jsp: param
              > verbose initialized to: true
              >Sun Apr 01 12:44:41 PDT 2001:<I> <ServletContext-General> *.jsp: param
              > packagePrefix initialized to: jsp_servlet
              >Sun Apr 01 12:44:41 PDT 2001:<I> <ServletContext-General> *.jsp: param
              > compileCommand initialized to: c:/java/java122/bin/javac.exe
              >Sun Apr 01 12:44:41 PDT 2001:<I> <ServletContext-General> *.jsp: param
              > srcCompiler initialized to weblogic.jspc
              >Sun Apr 01 12:44:41 PDT 2001:<I> <ServletContext-General> *.jsp: param
              > superclass initialized to null
              >Sun Apr 01 12:44:41 PDT 2001:<I> <ServletContext-General> *.jsp: param
              > workingDir initialized to: D:\releases\510\myserver\classfiles
              >Sun Apr 01 12:44:41 PDT 2001:<I> <ServletContext-General> *.jsp: param
              > pageCheckSeconds initialized to: 1
              >Sun Apr 01 12:44:41 PDT 2001:<I> <ServletContext-General> *.jsp: Using
              > Encoding : ISO-8859-1 when constructing PrintWriter instead of Servle
              >tOutputStream
              >Sun Apr 01 12:44:41 PDT 2001:<I> <ServletContext-General> *.jsp: initi
              >alization complete
              >Sun Apr 01 12:44:42 PDT 2001:<I> <ServletContext-General> looking for
              >taglib uri /counter.tld as resource /WEB-INF/counter.tld in Web Applic
              >ation root:
              >Sun Apr 01 12:44:43 PDT 2001:<I> <ServletContext-General> Generated ja
              >va file: D:\releases\510\myserver\classfiles\jsp_servlet\_pagehits.jav
              >a
              >Sun Apr 01 12:44:45 PDT 2001:<I> <ServletContext-General> file: init
              >
              >
              >what's the change number you get from weblogic.Admin VERSION?
              >
              >
              >--
              >Kumar
              >
              >Mike Reiche wrote:
              >
              >> From the zip file.
              >>
              >> It has to be a jsp that references those tag libraries.
              >> Other than that it works like a charm.
              >>
              >> Mike
              >>
              >> Kumar Allamraju <[email protected]> wrote:
              >> >Did you extracted the SP9 zip or exe?
              >> >I do not see the following errors when accessing a jsp with SP9? Could
              >> >you tell us how to
              >> >reproduce it?
              >> >
              >> >BTW, i will ask our docs folks to correct the startup scripts..
              >> >
              >> >--
              >> >Kumar
              >> >
              >> >Mike Reiche wrote:
              >> >
              >> >> I had to remove the 'async' attribute from taglib.tld
              >> >>
              >> >> And when I use WLCS I have to remove it from weblogic.tld
              >> >>
              >> >> And the startup scripts provided do not include weblogic-tags-510.jar
              >> >> in the classpath.
              >> >>
              >> >> Mike
              >> >>
              >> >> "Mike Reiche" <[email protected]> wrote:
              >> >> >
              >> >> >WLS 5.1, sp9 pre-release, solaris 2.7, WLCS 3.2
              >> >> >
              >> >> >JSP compile fails with the exception...
              >> >> >
              >> >> >weblogic.servlet.jsp.JspException: (line -1): Error in
              >> >> >tag library
              >> >> >at: 'wl':
              >> >> >The Tag class 'weblogicx.jsp.tags.CacheTag' has no setter
              >> >> >method
              >> >> > corresponding to
              >> >> >TLD declared attribute 'async', (JSP 1.1 spec, 5.4.1)
              >> >> > at weblogic.servlet.jsp.StandardTagLib.jspException(StandardTagLib.java:138)
              >> >> > at weblogic.servlet.jsp.StandardTagLib.processTag(StandardTagLib.java:264)
              >> >> > at weblogic.servlet.jsp.StandardTagLib.processTagElements(StandardTagLib.java:146)
              >> >> > at weblogic.servlet.jsp.StandardTagLib.<init>(StandardTagLib.java:125)
              >> >> > at weblogic.servlet.jsp.JspLexer.loadTagLib(JspLexer.java:95)
              >> >> > at weblogic.servlet.jsp.JspLexer.mTAGLIB_DIRECTIVE_BODY(JspLexer.java:3873)
              >> >> > at weblogic.servlet.jsp.JspLexer.mTAGLIB_DIRECTIVE(JspLexer.java:3623)
              >> >> > at weblogic.servlet.jsp.JspLexer.mDIRECTIVE(JspLexer.java:3484)
              >> >> > at weblogic.servlet.jsp.JspLexer.mSTANDARD_THING(JspLexer.java:1817)
              >> >> > at weblogic.servlet.jsp.JspLexer.mTOKEN(JspLexer.java:1658)
              >> >> > at weblogic.servlet.jsp.JspLexer.nextToken(JspLexer.java:1548)
              >> >> > at weblogic.servlet.jsp.JspLexer.parse(JspLexer.java:888)
              >> >> > at weblogic.servlet.jsp.JspParser.doit(JspParser.java:69)
              >> >> > at weblogic.servlet.jsp.JspParser.parse(JspParser.java:125)
              >> >> > at weblogic.servlet.jsp.Jsp2Java.outputs(Jsp2Java.java:109)
              >> >> > at weblogic.utils.compiler.CodeGenerator.generate(CodeGenerator.java:242
              >> >
              >
              

  • 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

  • Are not interpreted JSTL tags in a JSP page including in a servlet.

    Hi people,
    I have a project where una page (index.jsp) includes a servlet (MyServlet), that consult a persistence class and get a List of objects (Users),      
    then the servlet passes the List to a Request object and includes another JSP page (showUsers.jsp). And this is conceptually correct, but don´t works, the JSTL tags are not interpreted in showUsers.jsp.
    This is my code...
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <c:out value="Show me some things index.jsp"/>
    <div style="border-color:red; border:solid; padding-left:60px">
          <jsp:include flush="true" page="pepe/MyServlet"/>
    </div>
    </body>
    </html>...and the Servlet...
    public class MyServlet extends HttpServlet
         public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
              UserManager um = new UserManager();
              List users = um.getUsers(); //This use Hibernate to return a Users List
              request.setAttribute("users", (ArrayList) um.getUsers());
              request.getRequestDispatcher("/showUsers.jsp").forward(request, response);
    }...Finally, we have the showUsers.jsp file....
    <c:out value="Show me some thing showUsers.jsp"/>
    <table>
         <tr>
              <th>ID</th>
              <th>Name</th>
              <th>e-Mail</th>
              <th>Type</th>
         </tr>
         <tr>
              <c:foreach items="${requestScope.users}" var="user">
                   <td><c:out value="${user.id}" /></td>
                   <td><c:out value="${user.name}" /></td>
                   <td><c:out value="${user.email}" /></td>
                   <td><c:out value="${user.type}" /></td>
              </c:foreach>
         </tr>
    </table>This i get as result page...
    ID       Name       e-Mail       TypeFinally, this is the code of showUsers.jsp...
    <c:out value="Show me some thing showUsers.jsp"/>
    <table>
         <tr>
              <th>ID</th>
              <th>Name</th>
              <th>e-Mail</th>
              <th>Type</th>
         </tr>
         <tr>
              <c:foreach items="[src.User@18f729c, src.User@ad97f5, src.User@d38976, src.User@1e5c339, src.User@17414c8, src.User@7a17]" var="user">
                   <td><c:out value="" /></td>
                   <td><c:out value="" /></td>
                   <td><c:out value="" /></td>
                   <td><c:out value="" /></td>
              </c:foreach>
         </tr>
    </table>Somebody can help me?
    Many thanks,
    Gonzalo

    Thanks you all guys,
    I appreciate very much your help. In response to everyone ...
    BalusC wrote:
    Is JSTL taglib declared in top of that JSP page? I don't see it back in the posted code snippet. In this example I stuck...
    request.getRequestDispatcher("/showUsers.jsp").forward(request, response);By mistake, but this is just a test, the original line of my servlet is...
    request.getRequestDispatcher("/showUsers.jsp").include(request, response);As you can see, both (the servlet and the showUser.jsp file) are included in the index.jsp file. So the header...
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>...in the index.jsp file should works (I hope so).
    njb7ty wrote:
    I assume in your web.xml, you have ''pepe/MyServlet' defined as a servlet tag and servlet map tag? Without that, I don't think your JSP will find the servlet. I'm >not sure you need it in web.xml since I never call a servlet from a JSP page.
    I suggest putting System.out.println() throughout your servlet code and out.println() in your JSP pages to see exactly what is called and when.
    As a general rule, JSP files are to display data only, and submit back to a servlet. The servlet does all the business logic and dispatches to the appropriate >JSP page. The JSP shouldn't have any business logic. Including the servlet looks kinda like including business logic. Actually, in a MVC design, your >presentation, control, busines, and database layers have their own isolated responsibilities.
    I suggest the servlet put data as one java bean in request scope via request.setAttribute() and dispatch to the JSP page. The JSP page gets the data via ><useBean> tag. The JSTL gets the variables from the useBean tag and uses the data from there to display it. Really, this is my web.xml file...
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
         version="2.4">
         <servlet>
              <servlet-name>MyServlet</servlet-name>
              <servlet-class>src.MyServlet</servlet-class>
         </servlet>
         <servlet-mapping>
              <servlet-name>MyServlet</servlet-name>
              <url-pattern>/pepe/MyServlet/*</url-pattern>
         </servlet-mapping>
    </web-app>Regarding putting System.out.println() and out.println(), i did it and thats works.
    Respect of your last comment, I am not a expert in MVC, but I understand that the view layer can make calls to the Controller layer, I am wrong?
    evnafets wrote:
    It's not. However thats not code, but the generated HTML.
    As Balusc pointed out it's the result of running this JSP page without importing the tag library at the top.
    Because the tag library is not declared, it treats the <c:forEach> and other tags as template text, and basically ignores them.
    It then evaluates the ${items} attribute as an expression in template text, calling toString() on it.
    Cheers,
    evnafets      The file showUsers.jsp are included into the index.jsp page, that's have the header taglib. Could this works?
    BalusC wrote:
    njb7ty wrote:
    By the way, I dont think this is the correct format for the foreach tag:
    <c:foreach items="[src.User@18f729c, src.User@ad97f5, src.User@d38976, src.User@1e5c339, src.User@17414c8, src.User@7a17]" var="user">You're right friend.
    And that's my problem. Any ideas?
    Thanks everyone,
    Gonzalo

  • How to use Flex tag library in jsp

    Hi All,
    We are planning to use flex in our J2EE application in order
    to show some charts. Our j2ee application is in JSP,Struts. I have
    searched on google about this and found that I can include flex 3
    tab library in the jsp in order to use mxml tag in the jsp. I have
    written a sample program in the jsp which uses flex.
    <%@ taglib uri="FlexTagLib" prefix="mm" %>
    <SCRIPT LANGUAGE="JavaScript">
    function showMessage() {
    message.value = "Use this application wisely";
    function hideMessage() {
    message.value = "";
    </SCRIPT>
    <mm:mxml border="5" onmouseover="showMessage();"
    onmouseout="hideMessage();">
    </mm:mxml>
    <TABLE>
    <TR>
    <TD><input type="text" name="message"
    size="50"></TD>
    </TR>
    </TABLE>
    I have added entry inweb.xml. See below,
    <taglib>
    <taglib-uri>FlexTagLib</taglib-uri>
    <taglib-location>/WEB-INF/tlds/flex-bootstrap.jar</taglib-location>
    </taglib>
    Following are the problems that I am currently facing.
    1) Could anybody let me know whether the entry of
    <taglib> tag is correct in the web.xml. Is it the correct
    jar(flex-bootstrap.jar) that I should include?
    2) If yes, from where to download it? or
    If no, what is correct jar that i should include and how?
    your response will be highly appriciated as this is the major
    requirement in our project?
    Thanks ,
    Chandan

    Hi,
    Pleas find details at the URL below.
    http://labs.adobe.com/wiki/index.php/Flex_2_Tag_Library_for_JSP
    Hope this helps.

  • Error in parsing the taglib tag in the JSP page

    Hi
    We are trying to deploy and run a Web Application in CE 7.1 SP01. We are successful in deploying and running servlet based web pages, but when it comes to JSP's the taglibs are not parsed and we get the following error message
    Runtime error in processing of the JSP file E:\usr\sap\CE1\J01\j2ee\cluster\apps\sap.com\TestNWEAR\servlet_jsp\TestNW\root\admin\main.jsp.
    The error is: com.sap.engine.services.servlets_jsp.jspparser_api.exception.JspParseException: Error in parsing the taglib tag in the JSP page. Cannot resolve URI: [webwork]. Possible reason - validation failed. Check if your TLD is valid against its scheme.02004C4F4F5000190000004E000013400191D308B45
    Processing HTTP request to servlet [jsp] finished with error.
    The error is: java.io.FileNotFoundException: E:\usr\sap\CE1\J01\j2ee\cluster\apps\sap.com\TestNWEAR\servlet_jsp\TestNW\root\admin\webwork (The system cannot find the file specified)02004C4F4F50001900000051000013400191D308B45AF1AB
    We followed the below weblog to correct the TLD's in JAVA EE 5 @ SAP but it did not work for us.
    /people/community.user/blog/2006/10/13/porting-the-java-blueprint-solutions-catalogue-applications-to-sap-netweaver-application-server-java-ee-5-edition
    Any immediate help will be rewarded with full points
    Thanks in advance
    Lakshmi
    Edited by: lakshmi N Munnungi on May 5, 2008 11:36 PM
    Edited by: lakshmi N Munnungi on May 5, 2008 11:39 PM

    Hi Lakshmi,
    I have also the same problem. If you have found the solution please post it thanks,
    Thanks,
    Tariq

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

  • Urgent Solution needed--Problem in JSP compilation with JDK 1.5 and JDK 1.6

    Hi,
    I m using JDK 1.5 and Tomcat 5.0 the problem is that after starting server when I m going to access my application at that time instead of displaying HomePage it directly display the blank page on screen.
    After analyzing tomcat log I have found that there was a problem with JSP page compilation.
    The exception logged in Tomcat Log is given below
    An error occurred at line: 1 in the generated java file
    The type Collection is not generic; it cannot be parameterized with arguments <? extends E>
    Stacktrace:
    *     at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)*
    *     at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)*
    *     at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)*
    *     at org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)*
    *     at org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)*
    *     at org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)*
    *     at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)*
    *     at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)*
    *     at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)*
    *     at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)*
    *     at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)*
    *     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)*
    *     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)*
    *     at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)*
    *     at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:447)*
    *     at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)*
    *     at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)*
    *     at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:424)*
    *     at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:343)*
    *     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:144)*
    *     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)*
    *     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)*
    *     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)*
    *     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)*
    *     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)*
    *     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)*
    *     at java.lang.Thread.run(Thread.java:619)*
    After getting this kind of error I have analyzed my code furhter then I came to know that there was problem with static include tag.
    In my jsp page I have used following line which is the main cause of error
    <%@ include file="top.jsp" %>If I ommit this line then it is working properly.
    Instead of static include I have used jsp:include also.
    Still I m getting same problem.
    We have to migrated from JDK 1.5 to 1.6 and Tomcat 5.0.28 to 6.0.14, still same problem is there.
    We have tried a lot but didnt get success to overcome this problem.
    If anybody having any solution then ur each reply will be appreciated.
    Thanks in advance..........!!!!!!!
    Edited by: JBOSS2000 on Jan 15, 2008 9:29 AM

    Hi "mshanu" and "amit" Thanks for ur replies Here I m posting the code of "top.jsp"........!!!!
    <%@ page errorPage="errordisplay.jsp"%>
    <table cellpadding="0"
           cellspacing="0"  height=50 width=780>
           <tbody>
             <tr class="header">
               <td class="logo"><IMG SRC="assets/Logo.gif" BORDER=0 ALIGN=top></td>
               <td align="right"><span class="applicationtitle"><%@ include file="/contents/logo.htm" %></span><br>
               <span class="companyname"><%@ include file="/contents/companyname.htm" %></span></td>
             </tr>
            </tbody>
    </table>To include top.jsp I have tried
    <jsp:include page="top.jsp" flush="true">
    </jsp:include>
             AND       
    <%@ include file="top.jsp"%>but none of this worked.
    If I remove the include then It is working properly.
    But I need inluded file too so that I am wondoring for the solution.
    This problem seems very wiered to me. I dont know why it is happening.
    This problem is started only when I used the TOMCAT 6.14.
    Is it the bug of TOMCAT 6.14 or What somebody Plz help.
    I got stuck here.........!!!!!!!!!!
    It doesn't seem any problem with top.jsp. As per my thinking the problem is there in include due to that it doesn't compile the JSP page in Tomcat 6.0.
    Earlier I am having same code running on the Tomcat 5.0.28 and JDK 1.5.0.
    But problem occured when I have used Tomcat 6.x...!!

  • 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

  • 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

Maybe you are looking for

  • No photos in iphoto after update

    Hi looks like after teh latest update of iphoto, my entire library has gone!  Its there in time machine but doesn't seem to want to restore.  It gives me a message saying it wants to upgrade the thumbnails, but I seem to have been throught this loop

  • My mac pro has died, how can I see my emails on my macbook

    My Mac Pro has died. I intend to get it repaired, obviously, but I need to see my emails from the many years of emails archived on its undamaged hard drive. I have removed the hard drive and connected it to my macbook using a USB carrier. I can find

  • Footer needs to pull data from main table

    Hi Gurus, I need to have a footer which displays the value of a tag from the main table in BI publisher. The main table in the BI Publisher has the customer information and the address information of the customer needs to print on the footer of the p

  • HT3180 My Apple TV turns on but no image on TV screen

    My Apple TV has been unplug over 30 sec. or restart by using 3,4 button on remote but still no image on TV screen. The LED light blinking for a while and turn on for long without blinking. No image shown on screen. I have used for several times from

  • Projectors with ipad2

    I'm looking to buy a mini projector to work with iPad I was thinking of the Philips pico pix ppx1430. Will it work? Anyone tried it?