jsp: "Please wait ...."

Discussion in 'Java' started by Arnie, Jan 27, 2006.

  1. Arnie

    Arnie Guest

    I have a Servlet that does an extensive search which may take up to 1-2
    minutes to finish. I would like to display a "Please wait ...." page
    while the search is being performed and before the search results are
    displayed. How can I do this?

    thanks
     
    Arnie, Jan 27, 2006
    #1
    1. Advertising

  2. Arnie

    Guest

    There may be other options, but here is what came to my mind. The user
    is going to click a button/link to begin the search, right? This will
    submit the form or whatever. As soon as that button is pushed, the
    next page the user will see is the results from the search. There
    isn't really a way I know if to add a different page between those two,
    but you can use javascript to display a message while the search takes
    place. For example, if you are submitting a form...


    **** START CODE ****

    <script language="javascript">
    function doBeforeSubmit()
    {
    document.getElementById("displayBeforeSubmit").style.display =
    "none";
    document.getElementById("displayAfterSubmit").style.dispay =
    "block";
    return true; // you must return true or the form will not submit
    }
    </script>

    <div id="displayBeforeSubmit">
    <form action="results_page.jsp" method="post"
    onsubmit="javascript:doBeforeSubmit()">
    ...
    form stuff
    ...
    </form>
    </div>

    <div id="displayAfterSubmit">
    <h3>Searh processing. Please wait...</h3>
    </div>


    **** END CODE ****


    I think this should work unless the browser immediately displays the
    new page (results) but leaves that page blank while it waits for the
    server to process.

    However, I think it would look best to use AJAX (I think that stands
    for Asynchronous Javascript and XML). The idea behind this is that you
    can use only one page for everything. It's kind of hard to explain,
    but really not too hard to implement. If you are interested, let me
    know and I will explain.
     
    , Jan 27, 2006
    #2
    1. Advertising

  3. Arnie wrote:
    > I have a Servlet that does an extensive search which may take up to 1-2
    > minutes to finish. I would like to display a "Please wait ...." page
    > while the search is being performed and before the search results are
    > displayed. How can I do this?


    I would use a servlet. The servlet could check if the search is
    completed. If it's not the servlet would include a jsp with the please
    wait message. This jsp should contain a meta refresh tag, pointing to
    the same servlet, so that after n seconds the servlet is reloaded.
    If the search is completed the servlet can redirect to another page
     
    Andrea Desole, Jan 27, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stephajn Craig

    Implement a Please Wait Page

    Stephajn Craig, Jul 24, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    554
  2. Craig Deelsnyder

    Re: best way to do a "please wait" message

    Craig Deelsnyder, Aug 3, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    814
  3. joe kenney

    please wait.. page

    joe kenney, Aug 14, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    3,458
    S. Justin Gengo
    Aug 14, 2003
  4. Replies:
    0
    Views:
    4,511
  5. Nino
    Replies:
    3
    Views:
    2,312
Loading...

Share This Page