Solved

Displaying intermediate page/image while processing request by jsp code

Posted on 2004-04-16
12
4,654 Views
Last Modified: 2008-01-09
I have designed a create.jsp page to save data posted by info.htm but while processing this request it takes 5-40 secs.
Hence I want to display one page or image which will display message "Wait we are processing your request!"
I have tried this by adding html code to same  "create.jsp" page but it is not displaying that rather it is displaying   "Thank you" page after processing. To display Thank you page I am using  "response.sendRedirect" in jsp code. I want to disaply intermediate page before this "Thank you" page
Thanks!
Sanjeev



0
Comment
Question by:c_sanjeev
[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
12 Comments
 
LVL 28

Expert Comment

by:peakpeak
ID: 10844844
Many options ... though the solution involves many steps ...
Are you familiar with ASP and javascript (not jsp)? Are you prepared to bump up the points to 500?

Regards
Peter
0
 
LVL 19

Expert Comment

by:dakyd
ID: 10845527
One thing you might try is simply posting the data to the intermediate page, and then having the intermediate page re-post the exact same data.  create.jsp would then process the data after the intermediate page re-posts it.  Normally, this would just be an un-necessary step, but in this case, you *want* the intermediate page, so while the user waits, he/she sees the intermediate page.  Hope that helps.
0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 100 total points
ID: 10846572
You can handle it all right on the client as part of submitting the form.

Put the image and message in a hidden layer:

<div id="processing" style="position:absolute; top:100px; left:100px; z-index:10;display:none">
<img src="yourimage.gif">
<br />
wait we are processing your request...
</div>

Then do your submit button this way:

<input type="submit" onclick="showLayer();return false;">

Then put this function in the head of the page

<script type="text/javascript">
function showLayer()
{
   document.getElementById('processing').style.display='block';
   document.forms[0].submit();
}
</script>

The only thing you have to be careful of is that the layer is not displayed where you have a select, because it will not display on top of a select.

Cd&
0
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 

Expert Comment

by:usrfobiwan
ID: 10875931
I had the same kind a problem a few weeks ago with a asp coded upload page i created.

What I did was place a session("uploaded")=false on the start of the processing page.
and on the end of that page a session("uploaded")=true.

Then I created a popup window with a meta refresh and then checking the state of the session("uploaded"). If it is false the popup window showed a "please wait..." text and if the state of the session was true then closed the popup.

It was a plain and easy solution to come up with. So maybe you can also.

0
 

Expert Comment

by:BartRobeyns
ID: 10877063
You can handle it server-side in a very simple way (of course, this doesn't take browser-timeouts into account)

sleep.jsp:
-----------
Processing ...
<%
      out.flush();
      Thread.currentThread().sleep(5000);
      // do your stuff in stead of sleeping
%>
<hr>
Done
-----------
0
 

Expert Comment

by:augustd
ID: 10881513
If you don't mind using javascript you can take Bart's idea one step further and dynamically send javascript to refresh the page once processing is complete. Do something like this:

<%@ page
%>

<HTML><HEAD><TITLE>Processing your request</TITLE></HEAD><BODY>Processing...
<%
        out.flush();

        //do your stuff here
        Thread.currentThread().sleep(5000);
%>
<SCRIPT LANGUAGE="javascript">document.location="/done.jsp";</SCRIPT>
0
 

Expert Comment

by:ethereal11
ID: 10884060
What are you posting to? I had a problem where a servlet was taking a while to process something. I used x-multipart-encode to create a dynamic 'working' page that went to the solution when it was done.
0
 

Expert Comment

by:weejimmyoz
ID: 10885157
Here's some html that does pretty much what you want - note that it belongs in a frame.  The idea is that the target frame uses Javascript to display the 'waiting' message, launches the JSP action then uses the HTML returned from the JSP page to overwrite itself.  Works well for me...


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Application for something or other</TITLE>
<STYLE type="text/css">
  P.cSpan {text-align:center; font-size:large; font-family: Times, serif; font-weight:bold }
</STYLE>
<LINK REL="stylesheet" TYPE="text/css" HREF="styles.css">

<SCRIPT language="Javascript">
function doSpanText()
{
   document.all.plsWait1.innerText = "Please wait while your application is assessed.";
   document.all.plsWait2.innerText =" We may want to ask you some further questions.";
}
function extendSpanText()
{
   document.all.plsWait1.innerText += ".";
}
function doTimer()
{
   window.setTimeout("doAssess()", 2000);
}
function doWaitText()
{
   window.setInterval("extendSpanText()", 1000);
}
function doAssess()
{
   document.all.plsWait1.innerText = "Assessment in progress, please wait."
   document.all.plsWait2.innerText = " "
   doWaitText();
   parent.content.location.href="/xyz/eventHandler?application_id=999" +
                                "&event=ASSESS";
}
</SCRIPT>
</HEAD>
<BODY onLoad="doSpanText();doTimer()">
<div>
<br><br>
<center>Your application has been saved successfully.
</center>
<br>
<br>
<br>
<P class=cSpan>
<span id=plsWait1 ></span>
</P>
<P class=cSpan>
<span id=plsWait2 ></span>
</P>
</div>
</body>
</html>
0
 

Expert Comment

by:vandermask
ID: 10885692
You might idd do what COBOLdinosaur and BartRobeyns are suggesting:
a) if you submit the values (for processing) display a div with a flash movie or a gif displaying the wait-a-sec message
b) flush all the output to the client side
c) start processing your values
d) flush the rest of your page (after processing) to the client.  This part of the page will contain some JS which will hide the div

So you might get something like this:
<%
    if (request.getParameter("btnSubmit") != null)
   {
       //display you wait message
%>
<div id="processing" style="position:absolute; top:100px; left:100px; z-index:10;display:none">
<img src="yourimage.gif">
<br />
wait we are processing your request...
</div>
<%
       //flush output
       out.flush();
       //process all the values
       // ...
       // ...
       // Send rest of html including the part where hide the div
%>
<script type="text/javascript">
function showLayer()
{
   document.getElementById('processing').style.display='block';
   document.forms[0].submit();
}
</script>
<%
   }
%>

This might do the trick... (Credits to COBOLDinosaur, thanks for the HTMLCode ;o))
0
 

Author Comment

by:c_sanjeev
ID: 10885787
Thanks for all Tips. I tried all and found 'COBOLdinosaur' solution more close to my problem.
Only change I am doing is instead of calling showLayer() from submit I am calling it from validation check procedure after complete check of all validations!
Thanks!
Sanjeev


0
 

Author Comment

by:c_sanjeev
ID: 10897150
Handling this problem with 'COBOLDinosaur' solution is having one drawback of browser support.
Handling it at server side as per 'augustd' suggestion is more robust solution.
Thanks!
Sanjeev


0
 

Expert Comment

by:augustd
ID: 10901229
Coool. Could this be my first points?

But maybe we should address why your processing takes 40 seconds in the first place?
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Domain Service Not Responding 14 45
Any Way to rotate banner ads from Commission Junction? 2 54
calculate days away 11 59
ReadyAPI 1.9.0 2 37
Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

738 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