Solved

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

Posted on 2003-10-31
14
838 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Active Directory security has been a hot topic of late, and for good reason. With 90% of the world’s organization using this system to manage access to all parts of their IT infrastructure, knowing how to protect against threats and keep vulnerabil…

749 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