text: Q:
  
  add and retrieve elements from an array in Servlet Context
  
  I have an array in the Servlet Context and I would like to add and retrieve elements of this array from different servlets.
  How can I do this ?
  I do this for getting the entire list: 
      out.println(getServletContext().getAttribute("list"));
  
  list is the name of the array, so what can I do for adding an element to that list, and for getting the element with index 0 ?
  
  A:
  
  The code you posted prints the array to the out writer. To get a variable referencing the array, just do
  String[] array = (String[]) getServletContext().getAttribute("list");
  
  (assuming the array is an array of Strings, of course).
  
  