Iterating an ArrayList HashMap with JSTL in a JSP? Can it be done?

I made up the following code to iterate an ArrayList of HashMaps using JSTL Core in a JSP, but it doesn't work. However I've seen examples of similar code that works, so I'm not sure what's wrong with mine. Any help would be greatly appreciated.
<%
     FileBrowser fb = new FileBrowser();
     ArrayList list = fb.getFiles();
     request.setAttribute("list", list);
%>
<c:forEach var="file" items="${request.list}">
<c:out value="${file.path}"/>
</c:forEach>Yes I have triple checked that FileBrowser and all methods in it work just fine.

because the JSP is blank. but i accidentally fixed it. apparently i shoulda done ${list} instead of ${request.list} :p

Similar Messages

  • Create a hashmap with jstl, how?

    background:
    i need to create a hashmap on my jsp, using just jstl, if possible. after this, i need to pass this hashmap to custom tag, where the custom tag will get it like this:
    public void setSomeVar(Map m){ ... } 1. is this even possible?
    2. can anything other then a string be passed into a tag?
    thank you.

    mkoryak wrote:
    stevejluke wrote:
    You shouldn't generate a HashMap in JSTL*. Building a HashMap is business logic and the JSP should handle just display - and JSTL makes displaying data easier.while normally i would agree with you, i need to pass some stuff to my custom tag that looks very much like a map, so i would rather pass a real map, not a string which i would have to parse in the tag anyway. That is a worse situation than passing a HashMap. If I were you, I would either make setters for the expected keys of the HashMap (if they are known) in the JavaBean, or make the JavaBean a limited implementation of the Map interface that wraps around a local (to the JavaBean) Map, so you could directly set values without having to build a HashMap.
    I would also prefer to build the contents of the JavaBean in a Control servlet or in my Model layer, building it in the JSP is too much work.
    Example of a Map implementation in the bean:
    import java.util.Collection;
    import java.util.HashMap;
    import java.util.Map;
    import java.util.Set;
    public class MapWrapperBean<V> implements Map<String, V> {
         /* Holds a map of properties of unknown name and type */
         private Map<String, V> localMap = new HashMap<String, V>();
         /* Examples of a few normal bean properties */
         private String name;
         private int number;
         public MapWrapperBean() {}
         /* Normal Bean Property Accessors */
         public String getName() {
              return name;
         public int getNumber() {
              return number;
         public void setName(String name) {
              this.name = name;
         public void setNumber(int number) {
              this.number = number;
         /* Map interface wrapping around the local Map */
         @Override
         public void clear() {
              localMap.clear();
         @Override
         public boolean containsKey(Object key) {
              return localMap.containsKey(key);
         @Override
         public boolean containsValue(Object value) {
              return localMap.containsValue(value);
         @Override
         public Set<java.util.Map.Entry<String, V>> entrySet() {
              return localMap.entrySet();
         @Override
         public V get(Object key) {
              return localMap.get(key);
         @Override
         public boolean isEmpty() {
              return localMap.isEmpty();
         @Override
         public Set<String> keySet() {
              return localMap.keySet();
         @Override
         public V put(String key, V value) {
              return localMap.put(key, value);
         @Override
         public void putAll(Map<? extends String, ? extends V> externalMap) {
              localMap.putAll(externalMap);
         @Override
         public V remove(Object key) {
              return localMap.remove(key);
         @Override
         public int size() {
              return localMap.size();
         @Override
         public Collection<V> values() {
              return localMap.values();
    }>
    thanks for the help though, and yes, i should use the jsp forum, but know that ill get my answer here faster

  • Export a report from another page with parameter problems...can it be done?

    Hi All,
    I have used Dennis Excel pkg which works fine if on the same page... however, I want users to enter two dates in my items
    P5_FIRST_DATE
    P5_SECOND_DATE
    I have manged to create a button that will execute the report on the second page without parameters
    by choosing the redirect to url and this does work...
    however, when i parameterize the url, it still works but does not send across the values
    here is what i am using in the url
    #a href="f?p=102:7:3458199286078769:FLOW_EXCEL_OUTPUT_R2491013790251874" ##a href="f?p=102:0:3458199286078769:DOWNLOAD_EXCEL:NO::T_REGION_ID,T_EXCEL_NAME,T_PAGE,PFIRST_DATE:R2491013790251874,my_report,7,:P5_FIRST_DATE"
    This does work... but does not putt the parameters across
    Can this be done? or is there a better way of doing this. I dont really want them to see the report because it just a list of urns with dates which the user enters which they will always want to download
    so i just want them to add the dates and download
    thanks for your time in reading this
    cheers

    Fazlar,
    This is how you do it:
    http://apex.oracle.com/pls/otn/f?p=23521:8
    You should never name your items
    P5_FIRST_DATE
    and put the item on the page 8. This is confusing and costs a lot of time to find out an item
    doesn't exist.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://htmldb.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • I want to have 2 seperate libraries with content in different locations, can this be done?

    Hi there, I have 2 uses for itunes, one is for my mobile DJ business and for this I store all of my music on a 2TB external firewire 800 HDD I use Traktor Pro to mix, but find itunes very good for creating playlists.  I would however like to be able to store seperate content on my internal drive in a different library for personal use as a great deal of the stuff in my DJ collection I personally have no time for, and do not want the inconvenience of needing to connect my external HDD to be able to listen to my own collection.  I have a SSD installed and have tried depressing the CMD button during startup of the application although no option for creating a new library presents its self, it may be that the start up is too quick for me to be able out this.  Any ideas guys? Many thanks.

    Trying2loveMac wrote:
    Can this be done? If so, how?
    there may be other (better) ways out there but all i can think of is this:
    1) make one iTunes library the main one and "consolidate" files that aren't in it, but in the other computer's libraries, to it.
    you can use home sharing for this but home sharing won't copy ratings, playcounts, and original "date added". a 3rd party tool such as PowerTunes would be very useful if those details are important to you.
    2) once the "main" library is created, copy the entire iTunes folder (not just the iTunes music or media folder) to the media server, launch iTunes while holding the option(⌥) key, click on choose library when prompted, and select the iTunes folder you copied to the new location.
    3) repeat with the other Macs.
    with a setup such as this, be aware that only one iTunes at a time can access the library. if your intention is to enable multiple machines to access the library simultaneously, you will probably have look into a NAS with a built-in iTunes server.

  • Airport Extreme with a B&W G3.  Can it be done?

    So we're upgrading our network, we currently have a G5 IMac and B&W and we just purchased an IBook with the Airport Extreme station and a card for the IMac. We're currently running with a Linksys Router which also has my Xbox connected to it.
    My question is are there any products available to connect my B&W to the airport network? How would I do that? Now I know I can get a WiFi adapter for my Xbox, but will that work with the Airport Extreme basestation?
    Thank you very much. =)

    There are many options for your B&W G3. Probably the most elegant is to install a PCI wireless adapter card into it - see for example:
    http://www.macwireless.com/html/products/11g11bcards/11gPCI.php

  • I need to rename my itunes library, as I have two libraries on 2 different Mac's with the same name.  Can this be done?

    Hi, I have an iMac in one room and a Mac Mini in another.  Each is set up independantly and I unfortunately gave the same iTunes Library name to both libraries, which is now making it impossible for me to use my iPhone as a remote to both libraries.  I prefer to have 2 different libraries.
    Can I rename one library and if so, how?
    Cheers

    You can change the name from iTunes preferences.
    If you choose to share your entire library, its name appears in the iTunes window (below Shared) on other local computers set up to look for shared libraries. To change the name others see, choose iTunes > Preferences, click General, and type a new name in the Library Name field.
    From iTunes 10 for Mac: Share your iTunes library

  • Multi-clip with different video codecs. Can it be done?

    Is it possible to create a multi-clip when using different video codec (i.e. HDV 1080i50 & HDV 1080p25)?
    Thanks.

    Nope. Convert one to match the other using Compressor. Or better yet, convert them both to matching ProRes 422 files.
    Message was edited by: thrillcat editorial

  • Two computers with tv in the middle, can it be done?

    ?any suggestions?

    I am sorry to hear you are having issues, but this is the System Centre Mobile Device Manager forum. Please post on the appropriate forum for further help.
    Kind Regards
    Wayne Phillips

  • Re-attaching audio to sync with video??? can it be done in iMovie 09

    I've searched all over the web and I'm stuck. I've detached audio from a video clip so I can use that audio as a voiceover on other video footage. However, I'd now like to pin or re-attached that audio to the new video clip so it doesn't move while I edit my project. Can't find a solution for this - there must be one. Note that I'm not referring to a background music track I've added. I'm referring to audio which I've detached and now wold like to attached to a new video clip/portion of the project. Thanks for any help!

    can I take a music video from itunes an use it in my movie
    Isn't that a little like taking a couple of pages from Shakespeare to use in your next novel?
    I tried to import it but it seems to be in the wrong format or somthing.
    Copy protection will do that to a file.

  • Problem when iterating with JSTL

    hi ,
    i have occured a problem when iterating with JSTL
    althought this error,my application works fine but i would like to know why this error:
    ther is my iteration code:
    <c:forEach items="#{sWIMmoduleStatistiques.listeModules}" var="m">
               <h:panelGroup>
                <br>
                 <div class="connectorChartHeader" onclick="toggleImage('${m.nomChart}');" >
                <span class="headerTitle">${m.nom}</span>
            </div>
                   <br><br>
                   <img src="${m.nomChart}" id="${m.nomChart}" />
               </h:panelGroup> 
           </c:forEach>       
         the error is:
    javax.servlet.jsp.JspTagException: Don't know how to iterate over supplied "items" in <forEach>
         at org.apache.taglibs.standard.tag.common.core.ForEachSupport.toForEachIterator(ForEachSupport.java:274)
         at org.apache.taglibs.standard.tag.common.core.ForEachSupport.supportedTypeForEachIterator(ForEachSupport.java:238)
         at org.apache.taglibs.standard.tag.common.core.ForEachSupport.prepare(ForEachSupport.java:155)
         at javax.servlet.jsp.jstl.core.LoopTagSupport.doStartTag(LoopTagSupport.java:256)
         at org.apache.jsp.pages.modulesStatistiques_jsp._jspx_meth_c_005fforEach_005f0(modulesStatistiques_jsp.java:434)
         at org.apache.jsp.pages.modulesStatistiques_jsp._jspx_meth_h_005fpanelGrid_005f0(modulesStatistiques_jsp.java:399)
         at org.apache.jsp.pages.modulesStatistiques_jsp._jspx_meth_f_005fview_005f0(modulesStatistiques_jsp.java:181)
         at org.apache.jsp.pages.modulesStatistiques_jsp._jspService(modulesStatistiques_jsp.java:109)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
         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:630)
         at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
         at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
         at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
         at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:410)
         at com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:473)
         at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:141)
         at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
         at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:196)
         at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:109)
         at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
         at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
         at TimeoutFilter.doFilter(TimeoutFilter.java:60)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
         at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
         at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
         at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
         at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
         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:286)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
         at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
         at java.lang.Thread.run(Thread.java:595)

    that line generated an error:
    java.lang.NumberFormatException: For input string: "class"
         java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
         java.lang.Integer.parseInt(Integer.java:447)
         java.lang.Integer.parseInt(Integer.java:497)
         javax.el.ListELResolver.coerce(ListELResolver.java:166)
         javax.el.ListELResolver.getValue(ListELResolver.java:51)
         javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
         com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
         org.apache.el.parser.AstValue.getValue(AstValue.java:118)
         org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
         org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:101)
         javax.faces.component.UIOutput.getValue(UIOutput.java:184)
         com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:201)
         com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:284)
         com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:154)
         javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:861)
         javax.faces.component.UIComponent.encodeAll(UIComponent.java:946)
         javax.faces.render.Renderer.encodeChildren(Renderer.java:148)
         javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
         javax.faces.component.UIComponent.encodeAll(UIComponent.java:936)
         javax.faces.component.UIComponent.encodeAll(UIComponent.java:942)
         com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:271)
         com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:202)
         org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
         org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:196)
         com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:109)
         com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
         com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
         TimeoutFilter.doFilter(TimeoutFilter.java:64)
         org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
         org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
         org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
         org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)

  • What is the difference between iterator.remove() ArrayList.remove()?

    Following code uses iterator.remove() ArrayList.remove().
    public class CollectionRemove
        private static void checkIteratorRemove()
             List<String> list = new ArrayList<String>();     
              list.add("1");
              list.add("2");
              list.add("3");     
             System.out.println("in checkWithIterator*************");
            Iterator<String> iter = list.iterator();
            while (iter.hasNext()) {
                String str = iter.next();           
                if (str.equals("2")) {
                    iter.remove();
                System.out.println("list Size: " + list.size() + " Element: " +  str);
        private static void checkListRemove()
             List<String> list = new ArrayList<String>();     
              list.add("1");
              list.add("2");
              list.add("3");     
            System.out.println("in ncheckWithForLoop*************");
            Iterator<String> iter = list.iterator();
            while (iter.hasNext()) 
                 String str = (String) iter.next();    
                if (str.equals("2")) {
                    list.remove(str);
                System.out.println("list Size: " + list.size() + " Element: " +  str);
        public static void main(String args[])
             checkIteratorRemove();
             checkListRemove();
    output is :
    in checkWithIterator*************
    list Size: 3 Element: 1
    list Size: 2 Element: 2
    list Size: 2 Element: 3
    in ncheckWithForLoop*************
    list Size: 3 Element: 1
    list Size: 2 Element: 2Why is this difference ? what is the difference between iterator.remove() ArrayList.remove()?

    In the case of Fail-fast iterator, if a thread modifies a collection directly while iterating over it, the iterator will thow ConcurrentModificationException . Say,
    for (Iterator it = collection.iterator(); it.hasNext()) {
        Object object = it.next();
        if (isConditionTrue) {
            // collection.remove(object);  can throw ConcurrentModificationException
            it.remove(object);
    }As per specs,
    Note that this exception does not always indicate that an object has been concurrently modified by a different thread. If a single thread issues a sequence of method invocations that violates the contract of an object, the object may throw this exception. For example, if a thread modifies a collection directly while it is iterating over the collection with a fail-fast iterator, the iterator will thow this exception.

  • How to access the element s in a hashMap with order

    Does anybody know how to access the elements in a hashMap with order.
    I know set is a collection that doesn't gaurantee the order so the iterator of keySet will not gaurantee the order.
    Is there any way to solve this?
    Thanks

    If you mean the order in which the key/value pairs where added to the
    map, have a look at the LinkedHashMap class. If you mean 'natural'
    order, you shouldn't be using a HashMap at all then; have a look at the
    TreeMap class instead.
    kind regards,
    Jos

  • How do you run a boolean on a hashmap using JSTL?

    I am trying to test a hashmap to see if it has a certain value using JSTL.
    <jsp:useBean> id="something_map" class="java.util.HashMap" />
         <c:set target="${something_map}" property="submitted" value="goodbye" />
         ${something_map.submitted}
         <c:if test="{something_map.submitted == goodbye}">
         worked
         </c:if>
    I am creating a hashmap with the jsp:useBean tag. i set the maps name to "something_map."
    Then I made a key called submitted and set its value to goodbye.
    When I display "something_map.submitted", it successfully displays "goodbye", but when I run the <c:if> and test to see if "something_map.submitted" is equal to "goodbye", it doesn't work. How do I run a boolean on the value of a hashmap?
    p.s., i already tried using scope variables, but they don't work so well when they are updated several times over many pages.

    cotton.m wrote:
    >
    Also, to the person who said that I left out a $, that was I typo. I have it in on the original code and it didn't make a difference.Well it's not the equals bit. JSTL is a scripting language not Java.Sorry for the red herring. It's been a geologic age since I've done anything JSP-ish. I wasn't sure how closely JSTL aligns with the Java to which it compiles.

  • Problem with formatting date with JSTL ans swedish locale

    Hi,
    I have a strange problem with JSTL fmt:formatDate -tag and swedish locale.
    -------------------------- Extract from the JSP ------------------------------
    <jsp:useBean id="date" class="java.util.Date" />
    <fmt:formatDate value="${date}" pattern="dd.MM.yyyy HH:mm" />
    With en_US and fi_FI locales date is printed just the way I want: 29.04.2005 13:28 but in se_SE locale it is printed: Fri Apr 29 13:30:09 EEST 2005
    Has anyone had this problem before?
    Thanks in advance!

    Hi
    Try using "sv_SE" locale.

  • How to populate a form based on values in a database with JSTL?

    I know how to write Java code to connect to a database, but where exactly (and how) in my JSP page , using JSTL tags will I actually call the function that connects to the database?
    Should the code to connect and populate the Java Bean fields go into the JavaBean constructor or anther method ( but from what I understand I can't really call the Java Bean's methods through JSTL - unless I did it througha scriplet)

    I know how to write Java code to connect to a
    database, but where exactly (and how) in my JSP page
    , using JSTL tags will I actually call the function
    that connects to the database?You won't. The point of writing JSPs with JSTL is to realize that the purpose of JSP is to produce HTML, and not to do extraneous things like accessing databases. You would write a servlet that connects to the database, extracts the data, and puts it somewhere the JSTL can find it. (Most likely in a List object in request scope.)
    Then the servlet forwards to a JSP, where you use JSTL simply to scan through that List and convert the objects in it into HTML.

Maybe you are looking for

  • Displaying file items in-line

    I want to be able to display a HTML file that I have loaded into my content area in-line. You can do this with text items, but are limited to 32K. Are there any plans to enable this for file item types. Or has anybody done this before. URL items are

  • Windows Live Photo Gallery stopped importing and scanning from my printer.

    Windows Live Photo Gallery was allowing import and scanning from my printer.  All of a sudden this feature has stopped working.  I no longer get the dialogue box that asks whether I want to import documents or pictures... Could this be a setting issu

  • Pro Application Express book

    hello, I thought the book is even out until my brother told me after trying to order for it that it hasn't been released. To be honest, it saddened my heart. I need a real and practical oriented material urgently to help in my many projects. I hope w

  • Adding custom fields to Equipment master General tab ?

    Hi Gurus, I have requirement where in I need to add two custom fields in IE02/IE03. Completed part : 1. The new fields are added in the EQUI table in CI_EQUI structure. 2. Created a project in CMOD and linked enhancement ITOB0001 to it . 3. Activated

  • Can i create tablespaces later

    Hi all, please clear me.. currently i created one tablespace in production db with single datafile, can i create multiple tablespaces based on the usage later (like .. lob objects, indexes, table object etc) will it be fine! Thanks,