Creating a List of Maps and adding to Session

Description

This codeshare shows how to create a List of Maps of Strings, and to "set" and "get" the List on an attribute in the HTTP Session.

Code

${esc.h}set(${esc.d}photoList = ${esc.d}contents.getEmptyList())

${esc.h}set(${esc.d}photo = ${esc.d}contents.getEmptyMap())
${esc.h}set(${esc.d}dummy = ${esc.d}!photo.put("url", "/html/1.jpg"))
${esc.h}set(${esc.d}dummy = ${esc.d}!photo.put("link", "http://www.yahoo.com"))
${esc.h}set(${esc.d}dummy = ${esc.d}!photoList.add(${esc.d}photo))

${esc.h}set(${esc.d}photo = ${esc.d}contents.getEmptyMap())
${esc.h}set(${esc.d}dummy = ${esc.d}!photo.put("url", "/html/2.jpg"))
${esc.h}set(${esc.d}dummy = ${esc.d}!photo.put("link", "http://www.google.com"))
${esc.h}set(${esc.d}dummy = ${esc.d}!photoList.add(${esc.d}photo))

${esc.h}set(${esc.d}photo = ${esc.d}contents.getEmptyMap())
${esc.h}set(${esc.d}dummy = ${esc.d}!photo.put("url", "/html/3.jpg"))
${esc.h}set(${esc.d}dummy = ${esc.d}!photo.put("link", "http://www.dotcms.org"))
${esc.h}set(${esc.d}dummy = ${esc.d}!photoList.add(${esc.d}photo))

${esc.h}set(${esc.d}photo = ${esc.d}contents.getEmptyMap())
${esc.h}set(${esc.d}dummy = ${esc.d}!photo.put("url", "/html/4.jpg"))
${esc.h}set(${esc.d}dummy = ${esc.d}!photo.put("link", "http://www.hotmail.com"))
${esc.h}set(${esc.d}dummy = ${esc.d}!photoList.add(${esc.d}photo))

${esc.h}set(${esc.d}photoDimensions = ${esc.d}contents.getEmptyMap())
${esc.h}set(${esc.d}dummy = ${esc.d}!photoDimensions.put("width", "125"))
${esc.h}set(${esc.d}dummy = ${esc.d}!photoDimensions.put("height", "125"))

${esc.h}set(${esc.d}session=${esc.d}request.getSession())

${esc.h}set(${esc.d}v = ${esc.d}session.setAttribute("PhotoList",${esc.d}photoList))

${esc.h}set(${esc.d}list = ${esc.d}session.getAttribute("PhotoList"))

This is my photo list: ${esc.d}list