Results 1 to 3 of 3
  1. #1
    meodows92 is offline Member
    Join Date
    Nov 2014
    Rep Power

    Default How to run the servlet in the background

    Hi i am new here and also my skills is limited for java servlet, hope your can understand. I am doing a web development for a company, one of the function that they required is to generate a report on a user preference but when the user submit, the process or the codes will be generating in the background by the server and at the front of the JSP page may be have a message said "your item have being process, we will send an email once is done". But there is a problem with the servlet is that when i click on submit on top of the browser it have an loading icon. I don't want to let the user that the page is still loading, i want it to load on the background without the loading icon beside it. Is there any ways to solve this issue or how should i start as so that the servlet will run the code on the background? There is an image below you can take a look about it. Sorry for the grammer.
    How to run the servlet in the background-loading-servlet.png

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power

    Default Re: How to run the servlet in the background

    You possibly want to have some form of queuing system.
    The servlet gets the request for the report, which then hands it over to the queue.
    The servlet can then return its response.

    Got anyone there that knows Akka? That's another possibility.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Rep Power

    Default Re: How to run the servlet in the background

    There is a bit of a hack that might work: you can load the servlet which does the processing in an invisible iFrame. Then when it is done processing you let the servlet output only a call to a javascript function to report the status; this javascript function exists in the main page (and thus forms a way for the iFrame to "communicate" with the actual page). That is a really dirty way of doing something "in the background" without having to resort to a server-side job queue and a client side javascript polling situation.

    This article demonstrates how this works for processing a file upload in the "background" using an iFrame, you can adapt that solution to your own needs:

    AJAX file upload tutorial
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Replies: 1
    Last Post: 11-14-2013, 10:29 AM
  2. Replies: 13
    Last Post: 07-25-2013, 05:30 PM
  3. Replies: 1
    Last Post: 08-23-2011, 11:12 AM
  4. Replies: 1
    Last Post: 12-02-2008, 12:23 AM
  5. Replies: 1
    Last Post: 08-07-2007, 03:47 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts