I have a requirement that all servlets in an application to return
immediately and with a standard response. Any processing needs to be
done offline.

I could have the servlet log the request to a database for a separate
application to pick up. I do not want this solution as we have atleast
20 unassociated applications which would all need there own separate
process which would not take advantage of tomacts load sharing across
our web servers.

We are using an apache/tomcat webserver, java 1.4.2 and the standard
logger java.util.logging.Logger. My solution so far is for the servlet
to kick off a Thread (defined as an inner class in the same file as
the servlet) to do the work and let the doGet respond back to the
requestor.

This works fine with one problem. Logging.
Any logger calls in the thread log to catalina.out while logger calls
in the doGet log to the correct application log file defined in the
tomcat configuration.

Any ideas how this can be resolved ?

thanks in advance.
Bill

Below is a code snippet.

public class BillTestServlet  extends BaseServlet {

   static final Logger logger =
Logger.getLogger(BillTestServlet.class.getName());

   public void init(ServletConfig servletConfig) throws ServletException {
       super.init(servletConfig);
   }

   public void doPost(HttpServletRequest req, HttpServletResponse
res) throws ServletException,
           IOException {
       doGet(req, res);
   }

   /*
    * This last string in this competition is a number
    */
   public void doGet(HttpServletRequest req, HttpServletResponse res)
throws IOException {

       logger.info("before sleep");
       try {
           DoSomethingThread doSomethingThread = new DoSomethingThread();
           doSomethingThread.start();
       } catch (Exception e) {
       }
       logger.info("after sleep");

       acknowledge(res, "boo");
   }

   class DoSomethingThread extends Thread {

      public void run() {
           logger.info("start run");
           try {
               Thread.sleep(2000);
           } catch (Exception e) {
           }
           logger.info("end run");
       }
   }
}

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to