title: How to get all attributes names(nested or not) in Servlet Context and iterate if it's a map or list?
body: <p>I've tried to get attributeNames of a ill-maintained context, then use those names with reflection.</p>
  
  <p>Here's some pseudo code for a rough idea.
  E.g. I have an ArrayList and a HashMap in the context.</p>
  
  <pre><code>enum = getServletContext().getAttributeNames();
  for (; enum.hasMoreElements(); ) {
      String name = (String)enum.nextElement();
  
      // Get the value of the attribute
      Object value = getServletContext().getAttribute(name);
  
      if (value instanceof HashMap){
        HashMap hmap = (HashMap) value;
        //iterate and print key value pair here
      }else if(value instanceof ArrayList){
        //do arraylist iterate here and print
      }
  }
  </code></pre>