How to iterate ArrayList in jsp?

Hi All,
This is a strut question. In my BeAction.java I have req.setAttribute("PIMSite",site); where in I set the site object(Its a ArrayList) for my jsp page to display the
Site attributes. Following is the part of code in jsp that does the attribute display. site being ArrayList may contain 0 or 1 or more than one locations(objects)
[html]
<table border="0" cellpadding="0" cellspacing="0" class="appstablecolor" width="100%"> <tr valign="top" align="left"> <td width="100%" > <table border="0" cellspacing="1" cellpadding="3" width="100%" class="modulecontent"> <tr valign="top" align="left"> <td width="40%" bgcolor="#ffffff" ><span class="modulesubhead"><bean:message key="PIMBeGeoinfo.hqaddress" /> </td></span></td> <td width="20%" bgcolor="#ffffff"> <span class="modulesubhead"><bean:message key="PIMBeGeoinfo.countrygroup"/></span> </td> <td width="17%" bgcolor="#ffffff"><span class="modulesubhead"><bean:message key= "PIMBeGeoinfo.hqcam" /></span></td> <td width="23%" bgcolor="#ffffff"><span class="modulesubhead"><bean:message key= "PIMBeGeoinfo.partneradmin" /></span></td> </tr> <tr valign="top" align="left"> <td width="40%" bgcolor="#ffffff" ><bean:write name="PIMSite" property="headQuarter"/><br> <bean:write name="PIMSite" property="siteAddress1"/> <bean:write name="PIMSite" property="siteAddress1"/> <bean:write name="PIMSite" property="siteAddress1"/> <br> <bean:write name="PIMSite" property="siteCity"/> <bean:write name="PIMSite" property="siteState"/>, <bean:write name="PIMSite" property="siteZipCode"/><br> <bean:write name="PIMSite" property="sitePhone"/></td> <td width="20%" bgcolor="#ffffff"> <bean:write name="PIMSite" property="siteCountry"/></td> <td width="17%" bgcolor="#ffffff"><bean:write name="PIMSite" property="channelAcctMgr"/></td> <td rowspan="2" bgcolor="#ffffff" width="23%">Lisa Simpson<br> Peter Parker</td> </tr> </table> </td> </tr> </table>
[html]
My question is PIMSite being a ArrayList may have multiple of site objects in it. Here I have displayed only one site object by passing a location object. Actually, I would be passing a ArrayList with multiple site objects in it for me to display in jsp page. But, if they are multiple site objects in ArrayList
how can I display in above jsp/html code.
My question is how do I iterate the ArrayList and then display multiple html hierarchy in case of multiple site locations present in ArrayList??
thanks,
pp

Use h:dataTable.
Also see http://balusc.xs4all.nl/srv/dev-jep-dat.html

Similar Messages

  • How to display arraylist in jsp

    I try to display arrayList
    past from servlet
    my code looks like
    <%@ include file="/expires.jsp" %>
    <%@ page language="java" import="java.sql.*" contentType="text/html;charset=UTF-8"%>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>CEDARS</title>
    </head>
    <body>
    <% String allFound = (String) session.getAttribute("allFound");
    hallA mydata= new hallA();
        for(int j=0; j<allFound.length(); j++){
                          mydata=(hallA)allFound.get(j);  %>
                     <tr>          
                     <td>mydata.getUniversityN()</td>
                      <td> mydata.getName()</td>
                      <td>mydata.getRnumber()</td>
                      <td>mydata.getCurricumlum()</td>
                      <td> mydata.getGender()</td>
                      <td>mydata.getYear()</td>
                      <td>mydata.getMobilNo()</td>
                      <td>mydata.getEmail()</td>
                      <td> mydata.getFinalYear()</td>
                      <td> mydata.getPeriodOne()</td>
                      <td> mydata.getPeriodTwo()</td>           
                    </tr>          
           <%}%>  
    </body>
    </html> and I got the error like
    Servlet.service() for servlet jsp threw exception
    org.apache.jasper.JasperException: Unable to compile class for JSP:
    An error occurred at line: 13 in the jsp file: /showResultA.jsp
    hallA cannot be resolved to a type
    10:
    11:  
    12: <% String allFound = (String) session.getAttribute("allFound");
    13: hallA mydata= new hallA();
    14:     for(int j=0; j<allFound.length(); j++){
    15:                       mydata=(hallA)allFound.get(j);  %>
    16:                  <tr>          
    An error occurred at line: 13 in the jsp file: /showResultA.jsp
    hallA cannot be resolved to a type
    10:
    11:  
    12: <% String allFound = (String) session.getAttribute("allFound");
    13: hallA mydata= new hallA();
    14:     for(int j=0; j<allFound.length(); j++){
    15:                       mydata=(hallA)allFound.get(j);  %>
    16:                  <tr>          
    An error occurred at line: 15 in the jsp file: /showResultA.jsp
    hallA cannot be resolved to a type
    12: <% String allFound = (String) session.getAttribute("allFound");
    13: hallA mydata= new hallA();
    14:     for(int j=0; j<allFound.length(); j++){
    15:                       mydata=(hallA)allFound.get(j);  %>
    16:                  <tr>          
    17:                  <td>mydata.getUniversityN()</td>
    18:                   <td> mydata.getName()</td>
    An error occurred at line: 15 in the jsp file: /showResultA.jsp
    The method get(int) is undefined for the type String
    12: <% String allFound = (String) session.getAttribute("allFound");
    13: hallA mydata= new hallA();
    14:     for(int j=0; j<allFound.length(); j++){
    15:                       mydata=(hallA)allFound.get(j);  %>
    16:                  <tr>          
    17:                  <td>mydata.getUniversityN()</td>
    18:                   <td> mydata.getName()</td>
    Stacktrace:
         at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)I don't know how to fix it
    thnak you

    hi evnafets,
    thnak you
    for the reply
    I presume you have a session.setAttribute() call in your servlet? yes so what is the mistake I made?1. I put both standard.jar and jstl.jar under E:\apache-tomcat-6.0.10\lib
    2. I copy the tld into E:\apache-tomcat-6.0.10\webapps\Hall\WEB-INF\
    3. I change my xml to<?xml version="1.0" encoding="UTF-8"?>
    <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_5.xsd"
        version="2.5">
        <session-config>
            <session-timeout>10</session-timeout>
        </session-config>
             <welcome-file-list>
              <welcome-file>Hall1.jsp</welcome-file>
         </welcome-file-list>
        <servlet>
            <servlet-name>submit</servlet-name>
            <servlet-class>submit</servlet-class>
        </servlet>   
        <servlet-mapping>
            <servlet-name>submit</servlet-name>
            <url-pattern>/servlet/submit</url-pattern>
        </servlet-mapping> 
    <taglib>
        <taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri>
        <taglib-location>/WEB-INF/fmt.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
        <taglib-location>/WEB-INF/c.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>http://java.sun.com/jstl/sql</taglib-uri>
        <taglib-location>/WEB-INF/sql.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>http://java.sun.com/jstl/x</taglib-uri>
        <taglib-location>/WEB-INF/x.tld</taglib-location>
      </taglib>
    </web-app>jsp<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ include file="/expires.jsp" %>
    <%@ page import="java.util.*"%>
    <%@ page import="cedars.hallA"%>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>CEDARS</title>
    </head>
    <body>
    <% ArrayList allFound = (ArrayList) session.getAttribute("allFound"); %>
    hallA myData= new hallA();
    <c:forEach var="myData" values="${allFound}">
    <table>
      <tr>
        <td>${myData.name}"</td>
        <td><c:out value="${myData.name}"/></td>
        <td><c:out value="${myData.currculum}"/></td>
    </tr>
    </c:forEach>
    </table>
    </body>
    </html>
    *error is ���d�I: Servlet.service() for servlet jsp threw exception*
    *org.apache.jasper.JasperException: /showResultA.jsp(13,0) Attribute values invalid for tag forEach according to TLD*     at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
         at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
         at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:236)
         at org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:1198)
         at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:819)
         at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1507)
         at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)
         at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2386)
         at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2392)
         at org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
         at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)
         at org.apache.jasper.compiler.Validator.validate(Validator.java:1737)
         at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:178)
         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:306)
         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:308)
         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:687)
         at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:469)
         at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:403)
         at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
         at displayhallF.doPost(displayhallF.java:166)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:402)
         at org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:170)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
         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.StandardWrapperValve.invoke(StandardWrapperValve.java:228)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)
         at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
         at java.lang.Thread.run(Thread.java:619)
    {code}
    thank you                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to iterate List in jsp without using for loop

    Hi,
    I am developing a small application is struts. I have one ActionForm file which contain one List like getEmployeeDetailsList(). When I am using this list in jsp page for displaying data. I want to display it as employee name, employee address, employee designation and employee contact no. These all fields are available in the above list. Now what is the problem is that I am using logic:iterate method to iterate data. but this is not sufficient to display all records in order. like employee name should be in one table and they can be vertical not horizontal, employee address is also should be seperate. and same thing with employee designation and contact no. I don't want to use for loop to iterate this list. Please tell me about optionCollection for this list. only employee names should be one drop down and employee designation is also in another drop down.
    Please help. It is really urgent.
    Any help will be appreciated.
    Thanks in advance.
    Manveer

    I'm not sure what you problem is, but one thing you can do is to create a new class and pass the list into its constructor (and store it as a private variable). Then, provide a set of functions in the new class that extracts data from the list and returns it in a form that the various parts of the JSP page wants. For example, one function may return a sorted list of just the employee names. In this way, all the business logic for formatting the data into a form that JSP page likes is hidden inside the new class.

  • How to pass arraylist of object from action class to jsp and display in jsp

    I need to do the following using struts
    I have input jsp, action class and action form associated to that. In the action class I will generate the sql based on the input from jsp page/action form, create a result set. The result set is stored as java objects in a ArrayList object.
    Now I need to pass the arraylist object to another jsp to display. Can I put the ArrayList object in the request object and pass to the success page defined for the action? If this approach is not apprpriate, please let me know correct approach.
    if this method is okay, how can I access the objects from arraylist in jsp and display their property in jsp. This java object is a java bean ( getter and setter methods on it).
    ( need jsp code)
    Can I do like this:
    <% ArrayList objList = (ArrayList)request.getattribute("lookupdata"): %> in jsp
    (***I have done request.setattribute("lookupdata", arraylistobj); in action class. ***)
    Assuming the java object has two properties, can I do the following
    <% for (iint i=0. i<objList.size;I++){ %>
    <td> what should i do here to get the first property of the object </td>
    <td> what should i do here to get the first property of the object </td>
    <% }
    %>
    if this approach is not proper, how can I pass the list of objects and parse in jsp?
    I am not sure what will be the name of the object. I can find out how many are there but i am not sure I can find out the name
    thanks a lot

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

  • Session Problems: "Don't know how to iterate over supplied "items""

    Hi, I am developing my first application using Struts and JSP. The Action Form loads an object called reportGrid into session and I am trying to display it on a JSP page. Displaying simple variables works fine, but I can display an object. The error I receive is: Don't know how to iterate over supplied "items"
    My object is made up of a group of ArrayLists looks similar to this this:
            private List affiliateID;
         private List affiliateName;
         private List product1;
         private List product2;
         //etc for about 10 listsThe object is filled with data from a result set and placed into session like:
         HttpSession session = request.getSession();
         session.setAttribute("grid", reportGrid);The goal is to display each list in its own column in a HTML table.
    <table>
    <tr>
    <c:forEach var="affiliateName" items="${grid}">
              <td>
                   <c:out value="${affiliateName}" />
              </td>     
         </c:forEach>
         <c:forEach var="product1" items="${grid}">
              <td>
                   <c:out value="${product1}" />
              </td>     
         </c:forEach>
         <c:forEach var="product2" items="${grid}">
              <td>
                   <c:out value="${product2}" />
              </td>     
         </c:forEach>
    </tr>
    </table>I'm sure this has been asked before but I could not find any examples in the forums. I can place an ArrayList directly into session and iterate through using <c:forEach tags but when I try to do the same with an object it gives me the error " Don't know how to iterate over supplied "items" ".
    Does anyone have any examples of pulling and displaying an object in session which contains ArrayLists? I have been stuck on this same error for a while and any help will be greatly apreciated.
    James.          

    What is the type of grid?

  • c:foreach Don't know how to iterate over supplied "items"

    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;
    }

    Please don't post your problem multiple times http://forum.java.sun.com/thread.jspa?threadID=720679&messageID=4157979#4157979

  • How to iterate the webservice Data control result set?

    Hi all,
    How to iterate the webservice Data control result set? I have an jsff page where I am displaying the single UserDetails by webservice DataContol. As per my design requirement I should iterate the DataControl resultSet to get the user details and push the same in to Managed bean. Please help me how to do this, any sample code please to iterate the resultset and get the data from it.
       <?xml version='1.0' encoding='UTF-8'?>
       <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
              xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:c="http://java.sun.com/jsp/jstl/core">
       <c:set var="uiBundle" value="#{adfBundle['edu.syr.oim.uiBundle']}"/>
       <af:pageTemplate viewId="/templates/jsffTemplate.jspx">
        <f:facet name="fTop"/>
        <f:facet name="fCenter">
          <af:panelGroupLayout layout="scroll" inlineStyle="width:100.0%;">
       <af:panelTabbed id="pt1">
        <af:showDetailItem text="#{uiBundle.PRIVACYFLAGS}" id="sdi4">
                <af:panelGroupLayout id="pgl4" layout="scroll">
                  <af:spacer width="10" height="10" id="s3"/>
                  <af:panelFormLayout id="pfl6">
                    <af:panelLabelAndMessage label="#{uiBundle.STUDENTEMAIL}"
                                             id="plam35">
                      <af:outputText value="#{bindings.stuEmail.inputValue}"
                                     id="ot42"/>
                    </af:panelLabelAndMessage>
                    <af:panelLabelAndMessage label="#{uiBundle.STUDENTHOMEADDRESS}"
                                             id="plam39">
                      <af:outputText value="#{bindings.stuPermAddr.inputValue}"
                                     id="ot35"/>
                    </af:panelLabelAndMessage>
                    <af:panelLabelAndMessage label="#{uiBundle.STUDENTHOMEPHONE}"
                                             id="plam40">
                      <af:outputText value="#{bindings.stuPermPhn.inputValue}"
                                     id="ot37"/>
                    </af:panelLabelAndMessage>
                    <af:panelLabelAndMessage label="#{uiBundle.STUDENTCURRENTPHONE}"
                                             id="plam42">
                      <af:outputText value="#{bindings.stuCurrAddr.inputValue}"
                                     id="ot40"/>
                    </af:panelLabelAndMessage>
                    <af:panelLabelAndMessage label="#{uiBundle.STUDENTCURRENTPHONE}"
                                             id="plam36">
                      <af:outputText value="#{bindings.stuCurrPhn.inputValue}"
                                     id="ot38"/>
                    </af:panelLabelAndMessage>
                    <af:panelLabelAndMessage label="#{uiBundle.STUDENTACAINFO}"
                                             id="plam41">
                      <af:outputText value="#{bindings.stuAcad.inputValue}"
                                     id="ot36"/>
                    </af:panelLabelAndMessage>
                    <af:panelLabelAndMessage label="#{uiBundle.EMPHOMEADDRESS}"
                                             id="plam38">
                      <af:outputText value="#{bindings.empPermAddr.inputValue}"
                                     id="ot39"/>
                    </af:panelLabelAndMessage>
                    <af:panelLabelAndMessage label="#{uiBundle.EMPHOMEPHONE}"
                                             id="plam37">
                      <af:outputText value="#{bindings.empPermPhn.inputValue}"
                                     id="ot41"/>
                    </af:panelLabelAndMessage>
                  </af:panelFormLayout>
                </af:panelGroupLayout>
              </af:showDetailItem>
       </af:panelTabbed> Above is my jsff code. Here how/where to add the phase listener to paopulate the managed bean while page render. Do I need to iterate the DC to get and push the each parameter in to ManagedBean or is there any easy way to do this by EL mapping directly at jsff. Please clarify.
    Thanks
    kln

    That is what exactly I am trying right now. I am binding each of my page fragment outputText item in to backing bean and by that way trying to populate the values.
    But the issue here is, the backing bean method doesn't getting any value until I hit any of the link or the button in the fragment. While loading the page the bean set and get is null. If i hit any link or button it is filled up with the vaule. As per my design, I would like to populate the bean method along with page load before any user action. But cant able to do this!! :(
    Below is my sample code what I am trying right now
            <af:panelLabelAndMessage label="#{uiBundle.NETID}" id="plam13">
                      <af:outputText value="#{bindings.netid.inputValue}" id="ot4" binding="#{UserDataBean.netId}"/>
           </af:panelLabelAndMessage>
    backing bean ex:
    private RichOutputText netId;
    static String netidVal;
        public void setNetId(RichOutputText netId) {
           netidVal= netId.getValue() == null? "":netId.getValue().toString();
           this.netId = netId;
        public RichOutputText getNetId() {
           return netId;
        public String getNetIdVal() {
           return netidVal;
        }Thanks
    kln

  • How to display arraylist list on jsf page

    Hii all,
    i am having an jspx page where i want to display the value coming from a bean class getter..
    the getter is returning an Arrarylist of list
    and i want to display the entire array list on the jspx page when it gets loaded.
    The method is :-
    public ArrayList<List> getMyList() {
    myList=getDocumentProperties();
    return myList;
    How to iterate the entire list on jsf..??
    any idea..!!
    Thanks

    You can use <af:forEach> or <af:iterator> in an ADF Faces page to iterate over the items returned by the bean's getMyList() method:
    <af:forEach var="prop" items="#{MyBean.myList}">
      <af:outputText value="#{prop}"/>
    </af:forEach>If you want to iterate over the inner lists, then use a nested iterator:
    <af:forEach var="prop" items="#{MyBean.myList}">
      <af:forEach var="item" items="#{prop}">
        <af:outputText value="#{item}"/>
      </af:forEach>
    </af:forEach>Dimitar

  • Don't know how to iterate over supplied "items" in forEach&gt

    I try the following
    I have form , bean , servlet and JSTL
    in bean I have constructor like
    public MyForm(String a_item) {
    this.a_item = a_item;
    in servlet
    MYForm uf = new MyForm(a_item);
    userSession.setAttribute("underform", uf);
    in jstl
    I have
    <c:forEach items="${sessionScope.underform}" var="found">
    <table cellspacing="0" cellpadding="0" width="100%" border="0">
    <tr><td align="left" valign="top">
    <c:if test="${found.a_item=='on' }">
    <li> <input type="checkbox" name="a_item" checked></li>
    </c:if>
    </td>
    </tr>
    </table>
    I GET THE ERR Don't know how to iterate over supplied "items" in &lt;forEach&gt;
    HOW CAN I Persisting data by the request by as an object ??
    thank you!

    so you suggest the method oneConsidering that I said exactly the opposite, it is a mystery to me how you could possibly have drawn that conclusion. I don't intend to keep repeating myself or to keep clarifying statements that are already perfectly clear. If you don't understand something, please say so. But don't put words into my mouth thanks.
    that means all logical will be handle on bean and not servlet is needed?Once again I have no idea what you mean by this question.
    what is the role for the servlet in MVC?And I have no idea what you mean by this question either, or how it relates to this thread. A JSP is a servlet in case you didn't know.

  • Iterate list in jsp without  Bean

    Hi Techies ,
    I am having list without  bean which is from webservices , so how to iterate in jsp , can u send example code .....
    Thanks in advance ..
    Thangavel.L

    Which framework you are using???
    using struts or ????
    -vignesh

  • How can i access the jsp file in a asp file

    Hi every one..
    we have two projects one is developed in ASP and one is developed in JSP both are running in two different locations.
    now i want to include a jsp file from one project to ASP file in the other project.
    please tell me how can i insert the JSP file in ASP application.
    thanx in advance.

    Wouldn't that be an ASP question for an ASP forum?

  • How to print report in jsp page?

    excuse me,i am new to jsp
    may i know how to pritn report in jsp page or html?
    tq

    here is a hacked up example.. i ripped out a lot, so it may not compile, but you get the idea... the full version is really long and not much new info.. just all awt/display stuff...
    package rowe;
    import javax.swing.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    import java.sql.*;
    import utility.*;
    import java.awt.print.*;
    public class rowePrint extends JFrame implements ActionListener, Printable{
         String printType = "";
         static JButton j = new JButton("Print");
         FontMetrics fm;
         String jID, promotion, product, jComments;
         public void getInfo(int jid) {
              ResultSet rs;
              try {
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   Connection conn = DriverManager.getConnection("jdbc:odbc:rowe");
                   Statement stmt = conn.createStatement();
                   rs = stmt.executeQuery("select j.id as jID, j.comments, p.title as pTitle, p.product, p.packagingCartonCost, p.foldingQuarterCostPerM, p.foldingQuarterCostPerM, j.customizationOption as setupFee, p.perMcost, p.qtyCarton, d.name as dName, d.contact as dContact, d.email as dEmail, d.address as dAddress, d.city as dCity, d.state as dState, d.zip as dZip, d.phone as dPhone, d.fax as dFax, r.name as rName, j.totalQty, j.orderIn, j.estFreight, j.miscCost, j.coverSelection, j.imprintSelection from jobs j, promotions p, dealers d, reps r where j.promotion = p.id and j.dealer = d.id and j.rep = r.id and j.id = " + jid);
                   rs.next();
                   jID = rs.getString("jID");
                   jComments = rs.getString("comments");
                   promotion = rs.getString("pTitle");
                   product = rs.getString("product");
              } catch (Exception e) {
                   System.out.println("getinfo: " + e);
       public void actionPerformed(ActionEvent e) {
            if (e.getSource() instanceof JButton) {  
                   wookie();
         public void wookie() {
              PrinterJob printJob = PrinterJob.getPrinterJob();
              Paper paper = new Paper();
              PageFormat page = new PageFormat();
              paper.setImageableArea(0, 0, 600, 780);            
              page.setPaper(paper);
              printJob.setPrintable(this, page);
              try{
                   //printJob.pageDialog(page);
              //     if (printJob.printDialog()) {
                        printJob.print();
              } catch (Exception e) {
                   System.out.println("wookie1" + e);
         public static void main(String[] args) {
              rowePrint at = new rowePrint("Invoice");
              at.getInfo((new Integer(args[0])).intValue());
              at.drawShapes();
         //     at.wookie();
         public void drawShapes() {
              setBounds(0, 0, 670, 550);
              addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) {System.exit(0);}});
              j.setBounds(10, 10, 10, 10);
              j.addActionListener(this);
              getContentPane().setLayout(null);
              getContentPane().add(l);
              getContentPane().add(j);
              show();
         public rowePrint(String s){
              printType = s;
         public void paint(Graphics g) {
              g.setFont(new Font("Serif", Font.BOLD, 18));
              g.drawString(promotion, 20, 30);
              g.setFont(new Font("SansSerif", Font.PLAIN, 4));
              g.drawString("" + new java.util.Date(), 20, 37);
              g.setFont(new Font("Serif", Font.BOLD, 21));
              g.drawString("Rowe Furniture", 440, 35);
              g.fillRect(440, 40, 145, 25);
              g.setColor(Color.white);
              fm = g.getFontMetrics(new Font("Serif", Font.BOLD, 21));
              g.drawString(printType, 512 - (fm.stringWidth(printType) / 2), 60);
        public int print(Graphics g, PageFormat pf, int pi) throws PrinterException {
            if (pi >= 1) {
                return Printable.NO_SUCH_PAGE;
              paint(g);
            return Printable.PAGE_EXISTS;
    }

  • Help me!! How to use JavaScript with JSP ??

    I am using JDeveloper and I created a screen in JSP which uses a bean for database connectivity and retriving info onto the page.
    The page has a ListBox where list items are populated from the database.My requirement is
    whenever the list is changed the page shuold be refreshed with the selected item info.
    I tried to use 'JavaScript' for triggering the event with 'onChange' event of the ListBox.But the event is not getting invoked. I think JavaScript is not working with JSP.
    Please help me with how to Use javaScript with JSP or any other alternative where I can meet my requirement.
    I have one more question...I have gone through the JSP samples in OTN and I am trying do download the sample 'Travel servlet' which show list of countries...etc
    I have also gone through the 'readme' but I don't know how to extract .jar file.
    I would be great if you could help me in this.
    Thanks!!
    Geeta
    null

    We have a similar need. We have used Cold Fusion to display data from Our Oracle Database. We have a simple SElect Box in HTML populated with the oracle data. When someone selects say the State of Pennsylvania. then we have an On change event that runs a Javascript to go get all the cities in Pennsylvania.
    Proble we are having is that inorder for the Javascript to work , we currently have to send all the valid data.
    Do you know of any way to dynamically query the the Oracle database in Javascript

  • How to use EJB in JSP...urgent!!!

    hello,
    i am novice programmer in EJB.
    i am using weblogic 6.1 ...
    my problem is how to use EJB in jsp page.
    my code is as follow..but its not displaying any result.
    <%@ page import="javax.naming.InitialContext,
    javax.naming.Context,
    java.util.Properties,
    firstEJB.First,
    firstEJB.FirstHome"%>
    <%
         long t1 = System.currentTimeMillis();
         System.out.println(t1);
         Properties props = new Properties();
         p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.TengahInitialContextFactory");
         props.put(Context.PROVIDER_URL, "localhost:7001");
         Context ctx = new InitialContext(props);
         FirstHome home = (FirstHome)ctx.lookup("FirstEJB");
         First bean = home.create();
         String time = bean.getTime();
         bean.remove();
         ctx.close();
         long t2 = System.currentTimeMillis();
    %>
    <html>
         <head>
              <style>p { font-family:Verdana;font-size:12px; }</style>
         </head>
         <body>
              <p>Message received from bean = "<%= time %>".<br>Time taken :
              <%= (t2 - t1) %> ms.</p>
         </body>
    </html>
    please tell me the solution.

    Hi, I don't know if it may be the cuase of your problems, but you should narrow the Object obtained doing the lookup, like this:
    FirstHome home = (FirstHome) PortableRemoteObject.narrow(ctx.lookup("FirstEJB"), FirstHome.class);

  • How to display PDF in JSP using Iframe

    Hi All,
    I am using Struts 2. I am building my file in ActionClass with seperate Method like getGeneratedPDF() in which, I am setting header of response and writing into PDF.
    This method will be called from JSP by this way
    s:property value="getGeneratedPDF()" />
    But It displayed Junk Characters , and this PDF is not static (already Generated). It is generated and build on Fly.
    I have 2 questions 1 -- How to display PDF in JSP in proper way without Junk Character in it?
    questions 2 -- How to display it in Iframe?
    Please help me , If you know the solution.
    Thanks in Advance,
    Jimmy

    jamy_26 wrote:
    But It displayed Junk Characters , and this PDF is not static (already Generated). It is generated and build on Fly.A PDF file is a binary file, not a text file, and you're trying to display it as String. Of course you would get "junk characters". Have you ever tried opening a binary file (pdf, doc, jpg, xls, etc) using a text editor like Notepad?
    I have 2 questions 1 -- How to display PDF in JSP in proper way without Junk Character in it?Display it as binary stream, not as text stream. You can display it standalone, just let the link/form/addressbar URL point to some Servlet which writes the InputStream of the PDF file to the OutputStream of the response, along with a correct set of response headers (at least content-type, content-disposition and content-length), so that the browser can open it in the correct application (which is usually Acrobat Reader). If you want to embed the PDF file in a JSP, then one of the ways is indeed using the HTML <iframe> tag.
    questions 2 -- How to display it in Iframe? Just let the iframe URL point to the aforementioned Servlet.
    You can find here an example of a generic file servlet, you may find it useful to get the idea how to do it: [http://balusc.blogspot.com/2007/07/fileservlet.html].

Maybe you are looking for

  • How do I get replacement rubber feet?

    How can I buy replacement rubber feet for my Mac Book Pro?

  • How to rise an event in Popup

    What is a proper way of using a dynamic event in Popup in order to send a message from it to the main application? Thanks

  • Any news on CC Particle World not working on the new Macs?

    I discovered to my horror that CC Particle World doesn't work on the early 09 Mac Pros. Something about Adobe stuff not fully workable with the Nehalem processors. Any news on a solution?  I need my particle world!

  • Migrating database target to new host

    Hi, I have OEM Grid control 10.2.0.5 running on Red Hat Linux 64 bit I have a database target with version 9.2.0.6 and grid agent on this target host is 10.2.0.5. I want to migrate my this database target from current server to another server and nam

  • Premiere elements crashes when burning a DVD

    I'm trying to burn a slide show I've created.  It's a mixture of photoshop elements photo slideshow and edited videos, about 30 minutes long. But every time I try and burn it to DVD, premiere elements crashes.  It generally gets to about 30% through