List of objects in Jsp

Hi All,
I have list of object. each object has some fields. ex. item, type, zone. I want to retrieve it in jsp. Now i am using
<%List itemList = (List)session.getAttribute(Constants.ITEM); %>
<%     for(int i =0;i<itemList.size();i++){
NhopItemDef nhopItemDef= (NhopItemDef)itemList.get(i);
if(nhopItemDef!=null){
if(nhopItemDef.getItemType().trim().equals(Constants.BED_ZONE)){
%>
<tr >
<td class="tb_dred_left_bf" height="30">
<html:hidden property="item" value="<%=nhopItemDef.getItem()%>"/>
<%=nhopItemDef.getItem()%>
</td>
Please let me know how to implement it using logic:iterate or c:foreach. which is the best way to implement?
please provide some example codes here.
Thanks & regards
arullakshmi

arullakshmi wrote:
Hi All,
I have list of object. each object has some fields. ex. item, type, zone. I want to retrieve it in jsp. Example:<c:forEach var="item" items="${itemList}">
  <tr>
    <td>${item.name}</td>
    <td>${item.type}</td>
    <td>${item.zone}</td>
  </tr>
</c:forEach>For more information, check out a good [JSTL tutorial|http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSTL.html].
~

Similar Messages

  • How to display List of objects in jsp?

    Hi,
    I have a list containing Collection of bean objects.
    Now I want to display the values in the list of objects in a jsp using JSTL.
    Any body help me how to retrieve the bean objects from the List and how can i display that values in the jsp.
    Advanced Thanks,
    Mahendra

    Have you tried to use <:forEach></c:forEach> tag available in jstl?

  • JSP: How do display list of objects in jsp table?

    sorry that my question my confuse you, let me explain more.
    in my java class, have method : public List retrieveAllVacancies(); and it returns a list of available vacancies.
    on my jsp page, i want to display the vicancies in the table have 3 rows:
    vacancy title  |  location  |  contract type
    should i use some form of for loop or iterator to get the vacancies in the list? how does the jsp page get the list of objects?
    anyone can help me? thanks

    i found out the actual thing i look for is how to pass the vector to the jsp page.
    <table>                                                                                                    
        <%
             Vacancy vacancy= new Vacancy();
            Vector allVacancies = new Vector();
            *//allVacancies = (java.util.Vector)request.getAttribute("allVacancies");*
            if(allVacancies.size() == 0) 
                out.print("<br><br><br>     There are no vacancies available!!");
            else
        %>
        <tr>
            <td>Vacancy Title</td>
            <td>Contract Type</td>
            <td>Location</td>
        </tr>
        <%
            for (int i=0;i<allVacancies.size();i++)
                vacancy = (Vacancy)allVacancies.get(i);
         %>
        <tr>
            <td><% out.print(vacancy.getVacancyTitle());%></td>
            <td><% out.print(vacancy.getContractType());%></td>
            <td><% out.print(vacancy.getVacancyLocation()); %></td>
        </tr>
    <%
    %>
    </table>*//allVacancies = (java.util.Vector)request.getAttribute("allVacancies");*
    if i have this line, when i open the jsp page it will gives NullPoniterException.
    the following was what i found for the similar problem,
    You can add the Vector to the HttpSession with_
    session.setAttribute(String name, Object value)_
    or to the ServletRequest with_
    request.setAttribute(String name, Object value)._
    In the other JSP, retrieve the value with_
    session.getAttribute(String name)_
    or to the ServletRequest with_
    request.getAttribute(String name)._
    but i tried to do in this way it didn't work. for sure i didn't do it correctly. could anybody give bit more explanation about how to pass the Vector to the jsp page?
    any help would be appreciated.

  • Tag files, Lists, and object typing

    I'm passing a list of objects to a custom tag, created via a tag file.
    I can access object properties in the jsp page like this -
    <c:out value="${listOfItems[0].property}" />
    but inside the tag it doesn't work. It understands that its being passed a list and the number of items in the list but not the type of objects in the list. I think I need to declare the type of object that the list is returning but I'm unsure of th jstl way of doing this.
    advice?
    thanks

    JSTL uses introspection/reflection to call methods/access properties.
    It doesn't have to know the type of object in the list.
    How are you accessing this object in your tag file? Using EL again? That should work fine. If you use java/scriptlet code then you will need to cast the object.
    Have you declared the attribute that is being passed in? What type are you expecting? Default is String unless you specify otherwise.

  • Handle list of list of objects in actionForm

    Hi,
    In my struts application, I am getting results from database, based on my search query.
    In result, I am getting set of list of objects mean set contain lists and list contain objects.
    I am passing these values from my action class to jsp page using one bean class.
    Now I want to pass all changed value from jsp page to my next action class using actionForm.
    but problem is, How can I do. because there are set of list of objects.
    pls give me suggestion.

    <html:select property="allEntity" style="width: 200px">
                                  <html:option value="Select an Entity" selected />
                                  <html:optionsCollection property="entity" value"id" label="name" />
                                  </html:select>
    Action Form class:
         private Collection entity;
    private String allEntity;
         public Collection getEntity() {
              return entity;
         public void setEntity(Collection entity) {
              this.entity = entity;
    entity holds all values, you can use it in the action class.
    you can use below too:
    String name[] = request.getParameterValues("name");
    Message was edited by:
    skp71

  • Accessing list-backed properties in JSP

    Hello guys,
    I am trying to generate a dynamic form using the list-backed properties following the guide in
    http://struts.apache.org/struts-action/userGuide/building_controller.html#map_action_form_classes
    It works as a map but can't make it work as a list
    here is my jsp
    <html:form action ="/addTemplate.do">
         <%List attributesList = (List) request.getAttribute("attributesList");
                        Integer count = new Integer(attributesList.size());
                        session.setAttribute("count", count);
                        session.setAttribute("attributesList", attributesList);
                        for (int i = 0; i <= count; i++) {
                             String name = "value(addTemplate-" + i + ")";
         %>
    <!--make a list-->
              Attribute<%=i%>
                        <html:text property="<%= name %>"/>
              <br/>
              <%}%>
              <html:submit/>
              </html:form>and my bean
    public class AddTemplateForm extends ActionForm {
        private final Map values = new HashMap();
        public void setValue(String key, Object value) {
            values.put(key, value);
        public Object getValue(String key) {
            return values.get(key);
    }when I am trying to use a list , obviously modifying the bean and my jsp to
    String name = "value[" + i + ")";I am getting
    javax.servlet.ServletException: Exception thrown by getter for property value[0] of bean org.apache.struts.taglib.html.BEANusing a map I don;t really know how to get the properties values in the Action class
    Any help is appreciated

    try this.
    <html:select property="selectedCountries" multiple="true" size="4">
    <html:optionsCollection property="availableCountries" label="name" value="id">
    </html:select>
    public OptionsRecord
    // make corresponding setters and getters
    private String name;
    private String id;
    // constructor
    public OptionsRecord(String nm, String idd)
    name = nm;
    id = idd;
    ----- Form class ----
    public TestForm extends ActionForm
    // make setters and getters for the following.
    private String[] selectedCountries = new String[0];
    private Collection availableCountries = new LinkedList();
    init()
    availableCountries.add(new OptionsRecord("Australia", "001"));
    availableCountries.add(new OptionsRecord("Burma", "002"));
    availableCountries.add(new OptionsRecord("USA", "003"));
    Don't forget to reset selectedCountries to a new object.
    -----

  • Need to find out the list of objects under a Transport

    Hi ,
    My requriement is to programatically find the list of objects under the Transport.
    I tried using the table E071 but no luck is there any FM or table which gives me the list of objects assigned to the transport request
    Regards,
    kk

    TYPES: BEGIN OF ty_tasks,
            trkorr TYPE trkorr,
            trstatus TYPE trstatus,
            strkorr TYPE strkorr,
            as4user  TYPE tr_as4user,
           END OF ty_tasks,
           BEGIN OF ty_object,
            trkorr TYPE trkorr,
            as4pos TYPE ddposition,
            pgmid TYPE pgmid,
            object TYPE trobjtype,
            obj_name TYPE TROBJ_NAME,
            lang TYPE spras,
           END OF ty_object,
    SELECT-OPTIONS : so_trans FOR e070-trkorr
    *selection from table e070.
      SELECT trkorr
             trstatus
             strkorr
             as4user
             FROM e070 INTO TABLE it_tasks
             WHERE strkorr IN so_trans or
                   trkorr in so_trans.
    IF SY-SUBRC = 0.
    *selection from table e071 to get all the objects
    *under the respective task/request.
    data: g_trans type e070-trkorr,
          g_strkorr type e070-strkorr.
      SELECT trkorr
             as4pos
             pgmid
             object
             obj_name
             lang FROM e071 INTO TABLE it_object
             FOR ALL ENTRIES IN it_tasks
             WHERE trkorr = it_tasks-strkorr.
    hope it might be helpfull.
    regards ,
    aby

  • Best Practice for caching global list of objects

    Here's my situation, (I'm guessing this is mostly a question about cache synchronization):
    I have a database with several tables that contain between 10-50 rows of information. The values in these tables CAN be added/edited/deleted, but this happens VERY RARELY. I have to retrieve a list of these objects VERY FREQUENTLY (sometimes all, sometimes with a simple filter) throughout the application.
    What I would like to do is to load these up at startup time and then only query the cache from then on out, managing the cache manually when necessary.
    My questions are:
    What's the best way to guarantee that I can load a list of objects into the cache and always have them there?
    In the above scenario, would I only need to synchronize the cache on add and delete? Would edits be handled automatically?
    Is it better to ditch this approach and to just cache them myself (this doesn't sound great for deploying in a cluster)?
    Ideas?

    The cache synch feature as it exists today is kind of an "all or nothing" thing. You either synch everything in your app, or nothing in your app. There isn't really any mechanism within TopLink cache synch you can exploit for more app specific cache synch.
    Keeping in mind that I haven't spent much time looking at your app and use cases, I still think that the helper class is the way to go, because it sounds like your need for refreshing is rather infrequent and very specific. I would just make use of JMS and have your app send updates.
    I.e., in some node in the cluster:
    Vector changed = new Vector();
    UnitOfWork uow= session.acquireUnitOfWork();
    MyObject mo = uow.registerObject(someObject);
    // user updates mo in a GUI
    changed.addElement(mo);
    uow.commit();
    MoHelper.broadcastChange(changed);
    Then in MoHelper:
    public void broadcast(Vector changed) {
    Hashtable classnameAndIds = new Hashtable();
    iterate over changed
    if (i.getClassname() exists in classAndIDs)
    classAndIds.get(i.getClassname()).add(i.getId());
    else {
    Vector vc = new Vector();
    vc.add(i.getId())
    classAndIds.add(i.getClassname(),vc);
    jmsTopic.send(classAndIds);
    Then in each node in the cluster you have a listener to the topic/queue:
    public void processJMSMessage(Hashtable classnameAndIds) {
    iterate over classAndIds
    Class c = Class.forname(classname);
    ReadAllQuery raq = new ReadAllQuery(c);
    raq.refreshIdentityMapResult();
    ExpressionBuilder b = new ExpressionBuilder();
    Expression exp = b.get("id").in(idsVector);
    roq.setSelectionCriteria(exp);
    session.executeQuery(roq);
    - Don

  • How to use currentNode Object in jsp ???

    Hi all ,
    I have created a component for leftNav and i have a jsp in it.
    The currentNode Object the jsp is returning null.
    Please let me know why i am getting this .
    Thanks in advance !!

    CurrentNode implicit object return currentNode instance under which your script is running. Breadcrum are usually generated at run time using other resource path and may not belongs to current resource. In this case get path for that resource and adapt to Node Some thing like,
    for all resource in breadcrum
          Node eachNode  = resourceResolver.getResource().adaptTo(Node.class)
         Now you are in Node world
    Yogesh
    www.wemblog.com

  • How to validate a session object in jsp?

    Hi All,
    i am facing a problem.The problem is how to validate the session object object in jsp.I have written a java script by using a defined function as setInterval and has given 5 mintues if the user is idle and will show a pop up menu before time out the session but in case of page active still this pop up menu is coming. The java script as follows.
    function SetTimer(){
         //How long before timeout (should be a few minutes before your server's timeout
         //set timer to call function to confirm update
         if(timeoutMinutes)
         timerObj = setInterval("ConfirmUpdate()",60000);
    function clearTimerFn(){
              timerCount = 0;
              clearInterval(timerObj);
              //timerObj = setInterval("ConfirmUpdate()",60000);
    function ConfirmUpdate(){
         //Ask them to extend
         if(confirm("Your session is about to expire. Press 'OK' to renew your session.")){
              //load server side page if ok
              var url = "ajaxSessionchecker.do?sessionvalidate=sessionvalid";
              LoadXMLDoc(url);
    And in jsp i am calling this js function as
    <%session=request.getSession(false);
              if(session.getLastAccessedTime()==60000){ %>
              <script type="text/JavaScript">
         clearTimerFn();
    </script>
    <%}else{
    session.setMaxInactiveInterval(-1000);} %>
    could you pls help me out?

    The reason for doing this is when ever i come to this user.jsp from account.jsp with a different account number this user.jsp is not refreshed and i still
    see the same old user.jsp for the previous account that i naviated before. Also please let me know if there is any other approach to acheive this taskDoes refreshing the page by pushing F5 solve the problem?
    If so, then the browser is caching the page, despite your attempts to stop it.

  • How can I get the "pageContext" object in jsp page?

    Hi everyone:
    I want to get struts's DataSource object in jsp page.So I should get the PageContext object in jsp page.My code is:
    ///////////////////datatest.jsp///////////////////////////////////
         DataSource ds=(DataSource)pageContext.getAttribute(Action.DATA_SOURCE_KEY);
         conn=ds.getConnection();
              stm=conn.createStatement();
              rs=stm.executeQuery(insertsql);
    Is right?But I get the "NullPointerException" error in Tomcat.The connection pool in struts-config.xml is:
    <data-sources>
    <data-source key="mydatasource">
    <set-property property="autoCommit"
    value="false"/>
    <set-property property="description"
    value="MyWebSite Data Source Configuration"/>
    <set-property property="driverClass"
    value="org.gjt.mm.mysql.Driver"/>
    <set-property property="maxCount"
    value="4"/>
    <set-property property="minCount"
    value="2"/>
    <set-property property="password"
    value="qijiashe"/>
    <set-property property="url"
    value="jdbc:mysql://localhost:3306/myweb"/>
    <set-property property="user"
    value="lyo"/>
    </data-source>
    </data-sources>
    I can query the database in servlet.
    I think the method that I get the context is not right.Had someone get the pagecontext in jsp page?help :(

    Sorry I forgot that I had change the code:
    DataSource ds=(DataSource)pageContext.getAttribute(Action.DATA_SOURCE_KEY);
         conn=ds.getConnection();
              stm=conn.createStatement();
              rs=stm.executeQuery(insertsql);
    to the code:
    DataSource ds=(DataSource)pageContext.getAttribute("mydatasource");
         conn=ds.getConnection();
              stm=conn.createStatement();
              rs=stm.executeQuery(insertsql);
    mydatasource is the struts datasource in "struts-config.xml". I couldn't work

  • Dynamic List of Objects  OracleAS Portals

    <img class="emoticon" src="images/emoticons/confused.gif" border="0" alt="" />
    Hello hope someone can help me
    I have a <strong>List of Objects</strong>, the thing is that I want that list to give a <strong>parameter</strong>, so i can use it in a <strong>query</strong> for showing s<strong>pecific
    content</strong>, from a <strong>database</strong>, depending on the <strong>selected item</strong>, but is that posible, or should I use like a combobox or what do
    you recommend??
    <p>
    <strong>thanks in advance!! </strong><sup><strong> ^_^</strong>
    </sup>
    </p>
    Edited by: DunkelBlume on Sep 2, 2008 11:54 AM

    Hi,
    a list used in the singleSelectOne component does not change or set the currency in the list VO (in opposite to the navigation list). So this synchronization needs to be done programmatically. Examples of dependent list of values are available here
    --> example 62 http://radio.weblogs.com/0118231/stories/2004/09/23/notYetDocumentedAdfSampleApplications.html
    --> word document you can download from http://thepeninsulasedge.com/frank_nimphius/2008/05/16/blogbuster-treasures-hunt-blog-entries-from-the-lost-orablogs-blog-for-download/
    Frank

  • Entity object attribute with a list of objects

    Does anyone know how one sets up an entity object that has an attribute with a list of objects as the type? (assuming that's supported)
    as in:
    CREATE TYPE phones AS VARRAY(10) OF varchar2(10);
    Create table suppliers (supcode number(5),
    Company varchar2(20),
    ph phones);
    The SOA Suite in jDeveloper (new Entity Object/attributes etc) has an ARRAY that can point to REF or OBJECT. Neither work. When I try to Create DB Object later from the Entity Object I've created I get an invalid type.

    What you suggested about "validation codes on the VO" is not written on the ADF Documentation.
    I try to blindly/strictly follow best practices (particularly on Validations, using Declartive and/or built in validators) on most ADF documentation and blogs but there are many scenarios on coding some large ADF projects that I think must veer away from the best practices stated on the documentation or maybe add new rules on the documentation depending on how complex an ADF project would be.
    I religiously followed best practices stated on the documentation to use Entity and Attribute Validators when performing validations. What I did was i had created lots of Custom Validators (by implementing JboVAlidatorInterface interface) for each of the attributes on an Entity Object that need validated. So those validator is valid only for one attribute, its not reusable. And those validation codes either have reference to a ViewObject or call some PL/SQL procedure. So at some point are codes became messy.
    Ultimately the whole project became harder to manage when the codes became large. Now I am trying to refactor the whole application by separating it into project/package and I am hoping to do it with little Re-coding as possible.
    Hope to get your opinion on this one.
    regards,
    Anton

  • What is Piece List, Work List and Object List

    Hi All,
    Can you please give idea about Piece List, Work List and Object List in BI.
    What are their uses?

    Hi,
    Piece lists
    You can use this request type to set up your own object lists and save them under a name of your choice.
    For more info on this go through the link below
    http://help.sap.com/saphelp_sm32/helpdata/EN/57/38e1b64eb711d182bf0000e829fbfe/content.htm
    Worklists
    Worklists are the quickest and most convenient way of accessing the objects that you need to translate. Translators can call up a worklist in SE63 once a system has been completely set up for translation.
    For more info on this go through the link below
    http://help.sap.com/saphelp_sm310/helpdata/en/77/571a1f492011d1894a0000e829fbbd/content.htm
    Object Lists
    The Object Lists tab page in transaction SLWB enables you to create and manage object lists in the Translation Planner.
    An object list should contain all objects relevant for translation. You can create object lists according to a variety of criteria
    For more info on this go through the link below
    http://help.sap.com/saphelp_sm32/helpdata/EN/d4/341964249711d3b29e0000e817ab98/content.htm
    Regards,
    Marasa.

  • Best method for scrollable list of objects

    I was attempting to create a list of objects in a scrollable pane with the ScrollPane object. I am having a very hard time customizing what is actually scrolling in that pane, though. By using a custom renderer class, I am able to change what it looks like and even add objects to it, but I am having trouble passing data to those objects at creation because it is loaded through the pane object itself.
    What I would like to do is create an object with buttons on it (relative to that object) and be able to add multiple ones to a scrollable pane. I tried to figure out a way to be able to simply add my object as the item, but it seems to require a specific object. Is there any work around to this? What would be the best way of going about this?
    Thanks for any help.

    Class: java.sql.DatabaseMetadata
    Method: getSQLKeywords
    Desc: Returns a comma-delimited list of all non-SQL92 keywords used by the database
    Example (Source http://javaalmanac.com/egs/java.sql/GetSqlKeywords.html?l=rel ):
    import java.sql.Connection;
    import java.sql.DatabaseMetaData;
    public String[] getSQLKeywords(Connection connection) {  
       String[] keywords = null;  
       try {       
          DatabaseMetaData dbmd = connection.getMetaData();       
          keywords = dbmd.getSQLKeywords().split(",\\s*");   
       } catch (SQLException e) {
          // Handle Exception   
       return keywords;
    SQL92 Keywords
    The SQL92 specification is available for purchase. However, if you just want the full list of reserved words / keywords for a particular type of database, there is usually documentation provided by the database vendor.
    Full Keyword List Oracle 8.0:
    http://www-rohan.sdsu.edu/doc/oracle/server803/A54656_01/vol2_wor.htm#421705
    For Other Oracle Versions:
    - Visit technet.oracle.com
    - Register for free
    - Go to Documentation
    - Look under K for Keywords in index for newer versions of Oracle
    - Look under Programmer's Guide to the Oracle Call Interface for older versions of Oracle

Maybe you are looking for

  • ADF: Marker Texts Overlapping in Dual Y Graphs

    Hi, I am using a dual Y graph using ADF in which multiple series will be displayed in a graph. However, I am facing some issues in with the Marker Texts of different series as these are overlapping with one another. Please see my code snippet below :

  • Trouble starting up my iBook

    My iBook can't startup on its hard disk. It all started I noticed considerably slow reaction times to input and Safari kept crashing when I tried loading web pages. I restarted by holding down the power button. The iBook booted to the terminal. I res

  • Business Objects Edge 3.1 Installation Issue

    Hello, When installaling BO Edge 3.1, the setup up process is not asking me if 1) If I want to install My SQL database along with BO Edge. instead it is assuming that I have a database already installed while the fact is that I dont have any database

  • Select value based on a value in a 2nd column (similar to vlookup)

    Hello all, Is there an alternative to VLOOKUP function in BI 11g? Or what else I can use to return value of 3rd column based on the value in 2nd column? Dept Min_Expense Description of Expense Acct 1000 'COGS' Thank you.

  • How do I save the progress of TV shows I'm downloading?

    I have a VERY slow and unreliable internet connection, as I am currently deployed in Iraq. I'm trying to download some US TV shows that I have purchased, but it is taking approximately 25 hours per episode. Unfortunately, my internet isn't stable eno