[jboss-user] [Tomcat, HTTPD, Servlets & JSP] - How can I control infinite requests?

bunkenburg do-not-reply at jboss.com
Thu Feb 21 11:37:05 EST 2008


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);
  | 		}
  | 	}
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4131149#4131149

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4131149



More information about the jboss-user mailing list