Jahia Shared Map
The Jahia Shared Map is a map that is accessible by any portlets or Jahia templates.
Within Jahia, it’s stored as the user session attribute named "jahiaSharedMap" and can be retrieved with the following code:
Map sharedMap = (Map)session.getAttribute("jahiaSharedMap");
Within a portlet, it is stored as a portlet request attribute named "jahiaSharedMap". It can be retrieved with the following code:
Map map = (Map) portletRequest.getAttribute("jahiaSharedMap");
The Jahia Shared Map can be updated only during the processAction(…) or from a template.
Map map = (Map) actionRequest.getAttribute("jahiaSharedMap");
public void processAction(ActionRequest actionRequest, ActionResponse actionResponse) throws PortletException, IOException {
Map map = (Map) actionRequest.getAttribute("jahiaSharedMap");
if (map == null) {
map = new HashMap<Object, Object>();
}
map.put("date", new Date());
actionRequest.setAttribute("jahiaSharedMap", map);
}
If the portlet tries to modify the map during the render phase of the portlet, an exception is thrown.
public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException {
Map map = (Map) renderRequest.getAttribute("jahiaSharedMap");
if (map == null) {
map = new HashMap<Object, Object>();
}
map.put("date", new Date());
// an exception will be thrown
renderResponse.setAttribute("jahiaSharedMap", map);
}
Here is an example of execution:
![jahia6_6_portletguide_en-17.png [image]](/files/live/sites/jahiacom/files/documentation/6.6/en/images/PortletGuide/jahia6_6_portletguide_en-17.png)
Portlets A, B and C could be in different applications (contexts).

