Solved

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

Posted on 2003-10-31
14
829 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
xjc and jaxb 2 90
eclipse problems view not showing all the time 4 87
iterator example remove 8 74
java cigar challenge 58 206
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
A simple overview of the possibilities of using technology for project management.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now