Discussions

Web tier: servlets, JSP, Web frameworks: wait servlet message

  1. wait servlet message (9 messages)

    I have a Servlet, which is taking some time to process the request , because of the huge data. I have to show message on the browser to notify the user that the request is in process and have close it once the servlet sends data back to the browser. Thanks

    Threaded Messages (9)

  2. wait servlet message[ Go to top ]

    Hi,
    You can use the following header :

    <jsp:useBean id="tast" class="FormProcessingBean" scope="session">
    <%
    if(!test.isDone()) {
      response.setHeader("Refresh", "10");

    %>

    Please wait


    <%
    }
    else {

    Send result after processing

    }
    %>


    It will keep refreshing the page after 10 secs until your FormProcessingBean
    is done. Of course, FormProcessingBean has to process the request in a
    separate thread of execution.

    Good luck

  3. wait servlet message[ Go to top ]

    Thanks for reply and Can you help me how in servlets ?

    keerthikanth
  4. wait servlet message[ Go to top ]

    Hi, what I showed you using a java bean and not a servlet, try to create a simple java bean with setXXX and getXXX for all the fields in your database, create the connection in the constructor, and start playing with preparedstatment,

    good luck.
    Abdelmajid lotfi
  5. wait servlet message[ Go to top ]

    Can you be more specific.As i am using jsp pages and at one instance i send request to a remote server and it takes time to get the response and i want to show a wait page till the response is available. A clear answer will be highly helpful.Thanks
  6. wait servlet message[ Go to top ]

    Many said answers like Refreshing, threading , etc but nothing is working properly.I will post when I get the answer.
  7. wait servlet message[ Go to top ]

    Instead of invoking your servlet directly, serve up a static page that invokes the servlet using a META tag:

    <html>
    <head>
    <meta HTTP-EQUIV="refresh" content="0; url=/servlet/MyServlet?param1=param1">
    </head>
    <body>
    <h1>Please wait...</h1>
    </body>
    </html>

    The client will see the "Please wait..." page until the servlet returns a response.

    Vince Bonfanti
    New Atlanta Communications
  8. that almost works, but not quite[ Go to top ]

    The JSPs in my webapp check to make sure that the session is still valid before doing anything. Also, cookies are disabled so I use URL rewriting with the jsessionid.

    For some reason this causes the destination page to behave as though the session has expired.

    Let me explain more concretely:
    Here is the link to the wait page:
    <a href="<%=request.encodeURL(loading.jsp?url=foo.jsp)%>
    Click here to load a slow page</a>

    Here is the vital line from loading.jsp:
    <META HTTP-EQUIV="REFRESH" CONTENT="1;URL=<%=response.encodeURL(request.getParameter("url"))%>">

    So in this case, the desination url is foo.jsp, which calls code to make sure the session still exists (using the pageContext as a parameter). I definitely have the sessionID in my URL, but somehow the servlet container thinks it no longer has a valid session. I'm confused......

    Is there another way? Rewriting the servlet to be threaded is not an option in my case.
  9. solved my own problem[ Go to top ]

    Not sure why this worked, I would have thought it was functionally identical to a meta refresh tag. But I got rid of the meta refresh tag and replaced it with this:


    <SCRIPT LANGUAGE="JavaScript">
                setTimeout("location='<%=response.encodeURL(request.getParameter("url")).trim()%>'", 1000);
            </SCRIPT>

  10. sorry for the noise--but[ Go to top ]

    This will be my last post on the subject unless I come up with an incontrovertibly final solution. Basically, the previous solution worked on on my test and production systems using Firefox, but failed (as per my first post above) when using IE on the production, but not test system.

    Not sure why that is.

    But it does appear that every solution to this problem, (whether it's all in a simple JSP or involves a threaded servlet) makes use of a refresh header (either javascript or a meta tag). And that seems to be the weak link for me. Is there any solution that does not use one?

    I thought of using forward() but of course that won't work if you have already printed something (like "Please Wait") to your output stream.