Populating JavaScript Array from JSP List

Ok so perhaps someone can help me with a problem I’m trying to solve. Essentially I have a JSP page which gets a list of Country objects (from the method referenceData() from a Spring Portlet SimpleFormController, not entirely relevant but just mentioning in case it is). Each Country object has a Set of province objects and each province and country have a name field:

public class Country  {
    private String name;
    private Set<Province> provinces;

    //Getters and setters

public class Province {
    private String name;

    //Getters and setters

Now I have two drop down menus in my JSP for countries and provinces and I want to filter the provinces by country. I’ve been following this tutorial/guide to make a chain select in JavaScript.

Now I need a dynamic way to create the JavaScript array from my content. And before anyone mentions AJAX this is out of the question since our project uses portlets and we’d like to stay away from using frameworks like DWR or creating a servlet. Here is the JavaScript/JSP I have so far but it is not populating the Array with anything:

var countries = new Array();
<c:forEach items="${countryList}" var="country" varStatus="status">
    countries[status.index] = new Array();
    countries[status.index]['country'] = ${country.name};
    countries[status.index]['provinces'] =
        <c:forEach items="${country.provinces}" var="province" varStatus="provinceStatus">
            <c:if test="${!provinceStatus.last}">

Does anyone know how to create an JavaScript array in JSP in the case above or what the ‘best-practice’ would be considered in this case? Thanks in advance!

188 thoughts on “Populating JavaScript Array from JSP List”

  1. pharmacie herboriste bordeaux pharmacie auchan trignac , pharmacie en ligne oscillococcinum therapie jeu de sable , DГіnde comprar Sinemet 300 mg, DГіnde comprar Sinemet 300 mg. Comprar Sinemet sin receta Comprar Sinemet genГ©rico [url=https://kit.co/arfitla/donde-comprar-sinemet-300-mg-barato-sinemet-en-espana#]DГіnde comprar Sinemet 300 mg, Barato Sinemet en EspaГ±a[/url] therapies ciblees Tadalis SX en farmacia Venezuela, DГіnde comprar Tadalis SX 20 mg. Comprar Tadalis SX sin receta Comprar Tadalis SX genГ©rico [url=https://kit.co/ivunke/comprar-tadalis-sx-medicamento-tadalis-sx-en-farmacia-venezuela#]Comprar Tadalis SX medicamento[/url] , pharmacie de garde aujourd’hui porto vecchio pharmacie en ligne masque ffp2 , therapie gratuite. traitement gingivite pharmacie boulogne billancourt rue gallieni Comprar Quibron-t sin receta, DГіnde comprar Quibron-t 400 mg. Quibron-t en farmacia EspaГ±a Comprar Quibron-t genГ©rico [url=https://kit.co/lypurling/comprar-quibron-t-sin-receta-barato-quibron-t-en-espana#]DГіnde comprar Quibron-t 400 mg[/url] , therapie gestalt. pharmacie de garde voiron, pharmacie khun pharmacie herboristerie boulogne billancourt . pharmacie de garde xl, therapie de couple outaouais pharmacie lafayette givors horaires pharmacie annecy courier .

  2. Pingback: canadian viagra
  3. Pingback: discount viagra
  4. Pingback: viagra price
  5. Pingback: viagra pills
  6. Pingback: cialis 5 mg
  7. Pingback: viagra connect
  8. Pingback: order viagra
  9. Pingback: viagra 5 mg
  10. Pingback: cialis best price
  11. Pingback: cialis trial
  12. Pingback: sildenafil online
  13. Pingback: brand viagra
  14. Pingback: cialis vs viagra
  15. Pingback: viagra gum
  16. Pingback: viagra cock
  17. Pingback: levitra
  18. Pingback: online viagra
  19. Pingback: low price viagra
  20. Pingback: cvs viagra
  21. Pingback: viagra and cialis
  22. Pingback: sildenafil price
  23. Pingback: cialis dosis
  24. Pingback: stromectol 3g

Leave a Comment