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

#set($photoList = $contents.getEmptyList())

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

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

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

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

#set($photoDimensions = $contents.getEmptyMap())
#set($dummy = $!photoDimensions.put("width", "125"))
#set($dummy = $!photoDimensions.put("height", "125"))

#set($session=$request.getSession())

#set($v = $session.setAttribute("PhotoList",$photoList))

#set($list = $session.getAttribute("PhotoList"))

This is my photo list: $list