Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are a few items to discuss, each with their own (part of a) solution:</p> <ul> <li>Do you really want the task to continue if the browser closes? Spawn a new thread for the task (Trying to write to the browser outputstream when browser is already closed will make the thread die in an exception) See <a href="http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Executor.html" rel="nofollow noreferrer">Executor</a></li> <li>Do you want concurrent requests to be handled in parallel? How many in parallel? See <a href="http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ThreadPoolExecutor.html" rel="nofollow noreferrer">ThreadPoolExecutor</a></li> <li>Do you want feedback to the browser (user) during the long running task? See <a href="http://docs.oracle.com/javaee/6/api/javax/servlet/AsyncContext.html" rel="nofollow noreferrer">Async servlets</a></li> </ul> <p>The servlet container will make sure that parallel requests are handled concurrently, each in their own thread. But they will share the instance of the Servlet class. Therefore, you have to make your code <a href="https://stackoverflow.com/a/6324145/637423">thread</a> <a href="https://stackoverflow.com/a/9557412/637423">safe</a>.</p> <p>About running a 'separate java program' or keeping the task in the servlet: it is best practice to separate different tasks in a program in different sections. Creating a new class for your long running task is better than keeping it in the servlet class. See <a href="http://en.wikipedia.org/wiki/Separation_of_concerns" rel="nofollow noreferrer">Separation of concerns</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload