0 Replies Latest reply on Feb 21, 2008 11:36 AM by Alexander Bunkenburg

    How can I control infinite requests?

    Alexander Bunkenburg Newbie

      What happens if the programmer writes an infinite request?

      What if we have a servlet that may take a very long or infinite time to complete? Does that mean that every time some one sends a request to that servlet, one of the threads goes away to execute the servlet and never comes back? Is there any way that JBoss can monitor and kill such a thread?

      Example servlet:


       protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       try {
       String s = request.getParameter("N");
       int N = Integer.parseInt(s);
       PrintWriter writer = response.getWriter();
       for (int i=0; i<N; i++){
       writer.println(i + "/" + N);
       System.out.println(i + "/" + N);
       Thread.sleep(1000);
       }
       } catch (NumberFormatException e){
       throw new ServletException(e);
       } catch (InterruptedException ie){
       throw new ServletException(ie);
       }
       }