import java.io.*;
import java.net.URL;
import java.util.*;

import javax.security.auth.login.LoginException;
import javax.servlet.*;
import javax.servlet.http.*;
import net.mar.RetrieverManager;
import net.mar.RetrieverMapper;

import org.apache.log4j.Logger;
import org.astrogrid.community.common.exception.CommunityIdentifierException;
import org.astrogrid.community.common.exception.CommunitySecurityException;
import org.astrogrid.community.common.exception.CommunityServiceException;
import org.astrogrid.community.common.ivorn.CommunityAccountIvornFactory;
import org.astrogrid.community.common.security.data.SecurityToken;
import org.astrogrid.community.resolver.*;
import org.astrogrid.community.resolver.exception.CommunityResolverException;
import org.astrogrid.common.*;
import org.astrogrid.config.Config;
import org.astrogrid.config.SimpleConfig;
import org.astrogrid.registry.RegistryException;
import org.astrogrid.store.Ivorn;


public class Test extends HttpServlet {
  static Logger logger;
  int count=0;
  public void doGet(HttpServletRequest req, HttpServletResponse res)
                               throws ServletException, IOException {
//     res.
   res.setContentType("text/html");
  
      res.setBufferSize(100);
      res.setContentLength(30000);
    PrintWriter out = res.getWriter();
    doThis(out);
    for (int i=0; i <10;  i++) {
    try {
        Thread.sleep(100);
        out.print(i+"<!--                                              tada --><br>");
        out.flush();
        res.flushBuffer();
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    }
 /*   count=count+1;
    HttpSession session = req.getSession();
    out.println("<p>"+session .getAttribute("count"));
    out.println("<p>"+req.isRequestedSessionIdFromCookie());
    session.setAttribute("count",":"+count) ;
*/ 
  }

  void doThis(PrintWriter out){
      out.print("BASE");
  }
  protected void doPost(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
  {
    // Data received by an HTTP POST is handled the same way
    // as data sent with a HTTP GET request... simply pass on to above...
    doGet(req, res);
    
  }; // END of doPost()

}
