Solved

Display a message when JSP is waiting for a process to be completed

Posted on 2003-10-31
14
836 Views
Last Modified: 2012-06-22
How to display a message on the browser when JSP is waiting for a process to be completed.

Help urgent .....
Thanks
Arschie
0
Comment
Question by:aarschie
  • 4
  • 3
  • 2
  • +3
14 Comments
 
LVL 14

Accepted Solution

by:
kennethxu earned 64 total points
ID: 9658395
two options:

option 1:
write out the message and followed by <%out.flush()%;>, then start your process.

option 2:
use 2 pages,
in page1.jsp, use refresh header, e.g.:
<html>
<head>
<META HTTP-EQUIV=Refresh CONTENT="0; URL=page2.jsp">
</head>
<body>
please wait!
</body>
</html>

in page2.jsp, do your process.
0
 

Author Comment

by:aarschie
ID: 9658862
Actually I have first.jsp which calls a second.servlet to process the form fields. It takes couple of minutes to process it. I want to display a message on first.jsp once submit button is pressed to wait until the second.servlet is processed and redirects to another JSP.
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 9659281
use option 2 then. instead of redirect to page2.jsp, just use URL=second.servlet. e.g.
first.jsp submit to second.jsp

second.jsp:
<%
  // get necessary parameters and save then in session.
%>
<html>
<head>
<META HTTP-EQUIV=Refresh CONTENT="0; URL=servleturl">
</head>
<body>
please wait!
</body>
</html>

servlet:
get parameter form session stored by second.jsp. process and redirect to final.jsp
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 3

Assisted Solution

by:applekanna
applekanna earned 62 total points
ID: 9659855
Display a temporary page like we get in sites like expedia.com when you request a travel price search.

and then when you get the results just to a request dispatcher forward, from the servelt.
If you need more clarification do mail again
Hope this helps.
0
 
LVL 14

Assisted Solution

by:sudhakar_koundinya
sudhakar_koundinya earned 62 total points
ID: 9669795
page1.jsp

<%
   if(session.getAttribute("refresh")!=null)
   {
            //check whethere process is completed
            if(processcompleted)
            {
              session.removeAttribute("refresh");
            }
%>
<html>
<head>
<META HTTP-EQUIV=Refresh CONTENT="0; URL=page2.jsp">
</head>
<body>
please wait!
</body>
</html>
<%
   }
   else
   {
%>
            <html>
<!--             Your submission code to page2.jsp -->
            </html>
<%

   }

%>


page2.jsp

<%
   //process for your submission code
   session.setAttribute("refresh","true");
   response.sendredirect("page1.jsp");
%>
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 9669802
if you think session is burden use cookie
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 9669804
kennethxu,

i didn't see your code. My code is similar to yours. Sorry
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 9669810
Modified version of mine and  kennethxu's idea


page1.jsp

<%
   if(session.getAttribute("refresh")!=null)
   {
            //check whethere process is completed
            if(processcompleted)
            {
              session.removeAttribute("refresh");
            }
%>
<html>
<head>
<META HTTP-EQUIV=Refresh CONTENT="0; URL=page1.jsp">
</head>
<body>
please wait!
</body>
</html>
<%
   }
   else
   {
%>
            <html>
<!--             Your submission code to page2.jsp -->
            </html>
<%

   }

%>


page2.jsp

<%
   //process for your submission code
   session.setAttribute("refresh","true");
   response.sendredirect("page1.jsp");
%>
0
 
LVL 6

Assisted Solution

by:jarasa
jarasa earned 62 total points
ID: 9778243
Hi all.
There is a much easier way to display a message and it works faster and better besides you can make a good look. Just make a hidde <div> on your page and before submit you show it, it will be there until next page load in, and pop up inmediatly becose is already loaded.

But this is an HTML thing, anyway here you have the code:

<Script>
function sendForm() {
      document.all.processing.style.visibility = "visible";
      document.forms[0].submit();

}
</script>


<Form>
<Input type=button value="Send Form" OnClick="JavaScript:sendForm()">
</Form>
....
<div id="processing" style="position:absolute; z-index:100; top:140; left:265; width:280; height:134; clip:rect(0px 280px 134px 0px); visibility:hidden">
<table cellpadding=0 cellspacing=0 border=0 Width=100% Height=100% align=Center>
      <tr>
            <td width=125 align="center" class="v10blancong">
            
                  Put here the message you want, I use an animated GIF with a Clock and a moving message "Processing ....."
                  
            </td>
      </tr>
</table>
</div>


Have Fun
Javier
0
 
LVL 6

Expert Comment

by:jarasa
ID: 10756057
I don't want any points here It really does not matter but I believe that the answer I posted is as valid as any of the other ones, to tell the truth is faster and easier to implement, but....

:c)

Javier
0
 
LVL 35

Expert Comment

by:girionis
ID: 10756865
Yes your code should work, you are right. Sorry I should have actually included you in the split. I hope a moderator will also award some points to you.
0
 
LVL 6

Expert Comment

by:jarasa
ID: 10757107
As I said Girionis I'm not interested on the points, just on giving solutions, but .... :c)

Javier
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you are looking at this article, you have most likely been hit by some version of ransomware and are trying to find out if there is anything you can do, or what way you should react - READ ON!
Starting your own business is always a daunting process, and for most people it is brand new experience. Avoid the common pitfalls by following these tips to start on the road to success.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question