Solved

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

Posted on 2003-10-31
14
834 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ajax auto save 15 102
how to exclude a file using regex 5 118
doubleChar java challenge 7 106
java operators 3 116
Data breaches are on the rise, and companies are preparing by boosting their cybersecurity budgets. According to the Cybersecurity Market Report (http://www.cybersecurityventures.com/cybersecurity-market-report), worldwide spending on cybersecurity …
Adding Computers to AD groups through an SCCM Task Sequence
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
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…

803 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