Solved

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

Posted on 2003-10-31
14
828 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
if you think session is burden use cookie
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 14

Expert Comment

by:sudhakar_koundinya
Comment Utility
kennethxu,

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

Expert Comment

by:sudhakar_koundinya
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
As I said Girionis I'm not interested on the points, just on giving solutions, but .... :c)

Javier
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Find out what Office 365 Transport Rules are, how they work and their limitations managing Office 365 signatures.
A procedure for exporting installed hotfix details of remote computers using powershell
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 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

15 Experts available now in Live!

Get 1:1 Help Now