public class WeatherDisplay extends HttpServlet {
   protected void doGet(HttpServletRequest httpServletRequest,
         HttpServletResponse httpServletResponse) throws 
         ServletException, IOException {
      StringBuffer buf = new StringBuffer("<ajax-response>");
      try {
         Map[] map = WeatherManager.getAllWeather();
         for(int i = 0; i < map.length; i++) {
            buf.append(getRicoResponse(map[i],i));
         }
      } catch (JDOMException e) {
         throw new ServletException(e);
      }
      buf.append("</ajax-response>");
      AjaxUtil.sendXML(httpServletResponse,buf.toString());
   }

   protected void doPost(HttpServletRequest httpServletRequest, 
         HttpServletResponse httpServletResponse) throws 
         ServletException, IOException {
      doGet(httpServletRequest, httpServletResponse);
   }

   private String getRicoResponse(Map map,int counter) {
      StringBuffer buf = new StringBuffer(
         "<response type=\"element\" id=\"");
      buf.append((String)map.get("id")).append("\">\n");
      buf.append("<img src=\"/parkerriver/ajaxhacks/img/").
         append((String)map.get("img"));
      buf.append(".png\"/>");
      buf.append(" <span id=\"rng_").append((String)map.get("id")).
         append("\" class=\"therm\">high :: ");
      buf.append((String)map.get("hi")).append("; low :: ").
         append((String)map.get("low"));
      buf.append("</span>\n");
      buf.append("<span id=\"dt").append(counter).
         append("\" style=\"visibility: hidden\">").
         append((String)map.get("date"));
      buf.append("</span>\n</response>");
      return buf.toString();
   }
}
