Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show HTML content

Status
Not open for further replies.

Vadim

Programmer
Feb 5, 2002
75
US
Is it possible to show html content of JSP page before java parts completed?
I meen to display "Wait ..." untill jsp retreives all info.
This page is open in new window: in order to get result and return it to opener. After it received it it will close itself. If it is not possible to show "Wait..." message, is it possible made a new window invisible while it is working?

Thank you.
 
I came across the same problem before and get this one from a message board....It worked for so it should work for you as well..
The problem with JSPs (and HTTP in general) is there is a clear separation between code on the client server and code on the client.
That is, you cannot generally have code running on each end depending on each other. A request is sent to the server, it processes the request and a response is sent back to the client.

The best way I've encountered to do this is to use an intermediate 'Please Wait' page. Essentially the client sends a request to a 'fake processing servlet', this servlet returns a 'please wait' page and sends the original request to the real processing servlet.

The advantage here is that the 'Please wait' page is the one that is displayed while the long processing takes place.


<code>
<!-- START PAGE -->
<!-- This is the page where you enter the details -->
<form action=&quot;FakeServlet&quot;>
<input type=&quot;text&quot; name=&quot;username&quot;>
<input type=&quot;submit&quot;>
</form>
<!-- END -->
//-- FakeServlet
//this servlet can parse but not process the data
...start stuff
getRequestDispatcher(&quot;pleaseWait.jsp&quot;).
forward(request,response);

//-- END
<!-- pleaseWait.jsp -->
<!-- This is the page where the form is ACTUALLY submitted --> PLEASE WAIT <!-- this is the message shown while the page submits -->
<form name=&quot;auto&quot; action=&quot;FakeServlet&quot; action=&quot;ProcessServlet&quot;>
<input type=&quot;hidden&quot; name=&quot;username&quot; value=&quot;<%=request.getParameter(&quot;username&quot;)%>&quot;>
</form>
<!-- this script submits the form AFTER it has been completely loaded -->
<script>
document.auto.submit();
</script>
<!-- END -->
//-- Process Servlet

//and finally do the stuff that takes a long time
for(int i=0;i<10000000;i++) {
//etc
}
//-- END
</code>

Libaax
Hakuna Matata....;)
 
seems to me all you need to do is buffer your page, write your message, flush the buffer and let the page continue processing. in asp i do it like so:


<%
response.buffer = true
response.write(&quot;please wait...&quot;)

rem really long processing here...

rem need to redirect with js since we've written output already (response.redirect won't work)
%>
<script type=&quot;text/javascript&quot;>
location.href = &quot;newPage.html&quot;;
</script>


=========================================================
try { succeed(); } catch(E) { tryAgain(); }
-jeff
 
jemminger:
that concept did not work for ASP (if i am correct). i tried to help someone using that method. but it seems that the page loads only after the entire script is executed...

Known is handfull, Unknown is worldfull
 
oops...it works fine because i use it with an app here at work...i did forget the most important line though:

<%
response.buffer = true
response.write(&quot;please wait...&quot;)
response.flush

rem really long processing here...

rem need to redirect with js since we've written output already (response.redirect won't work)
%>
<script type=&quot;text/javascript&quot;>
location.href = &quot;newPage.html&quot;;
</script>




=========================================================
try { succeed(); } catch(E) { tryAgain(); }
-jeff
 
i will try that...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top