Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

JSP Processing

Posted on 2006-06-02
20
Medium Priority
?
290 Views
Last Modified: 2012-06-27
I have a situation where by I want to display an image to the user such as a an animated image eg clock whilst the page is doing some processing ie simular to websites when you are searching for flights and hotels.

Once the search is complete I want to redirect the user to another page.

How can this be done using html/javascript in a Java Server Page
0
Comment
Question by:inzaghi
  • 7
  • 4
  • 2
  • +3
18 Comments
 
LVL 8

Accepted Solution

by:
colr__ earned 500 total points
ID: 16816364
In your page that takes the sarch term, specify both an action and also a onsubmit command, like the following:

<form action="processSearch.jsp" onsubmit="doSearch()">

Also in your html, you want to add your canimated clock, but hide it using stylesheets:

<div style="visibility:hidden;" id="clock"><img src="..."></div>

In your javascript fiunction, set the clock as visible via the following:

document.getElementById("clock").style.visibility = "visible";

This will make the cloc visible until the search page completes, at which point the user is tranferred to te search results page.

You can see this code in working order here: http://www.iwanthits.co.uk/tools.asp

colr__
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16816390
You coudl use an applet
0
 
LVL 14

Expert Comment

by:hoomanv
ID: 16816824
see this script
http://bokehman.com/loading
0
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!

 

Author Comment

by:inzaghi
ID: 16817459
Suppose I dont want the form to submit to another page but whilst the search results are being retrieved in the jsp, how can the animated gif be displayed whilst the form is being rendered.

0
 

Author Comment

by:inzaghi
ID: 16817907
Come on experts need your help big time.
0
 

Author Comment

by:inzaghi
ID: 16818200
<form action="processSearch.jsp" onsubmit="doSearch()">

Also in your html, you want to add your canimated clock, but hide it using stylesheets:

<div style="visibility:hidden;" id="clock"><img src="..."></div>

In your javascript fiunction, set the clock as visible via the following:

document.getElementById("clock").style.visibility = "visible";


In the above case I will not be submitting a form but the jsp will be invoked which will do the processing.
How can I display the animated gif uptill the point page is rendered.

e.g assuming this is my jsp

display the gif

do business logic

business logic completed

render form
0
 
LVL 92

Assisted Solution

by:objects
objects earned 500 total points
ID: 16820991
The page has no idea when business logic is complete (because it is being run on he server)
So it needs to estimate the time and refresh at that point. If processing is still occurring then redisplay the gif o/wise render the form.
0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 500 total points
ID: 16822744
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16823652
Yes if you have to do asynchronous kind of processing in a web-app, the best option is probably to use Ajax. That's also what Gmail and Orkut use.
0
 

Author Comment

by:inzaghi
ID: 16831638
cant I use the onload method of the form?
0
 
LVL 8

Expert Comment

by:colr__
ID: 16831646
onload only works in the body tag, since its the page that loads as opposed to the form itself.

colr__
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16831668
>> cant I use the onload method of the form?

It would be called only once, when the form loads. From the sounds of your requirement, you probably need to run some logic multiple times even after form-load.
0
 

Author Comment

by:inzaghi
ID: 16831676
I only want to display the gif uptil the point the jsp page starts to render its display values to the user
0
 

Author Comment

by:inzaghi
ID: 16831679
similar to any sites such as lastminute.com
0
 
LVL 8

Expert Comment

by:colr__
ID: 16831693
You can do this via the method Ive shown you above, but changng it slightly.

Whenever the first result is created and sent to the browser, just before this, set the visibility of the clock to be hidden (as per my post above). This will hide the clock and show the results as they are generated.

colr__
0
 

Author Comment

by:inzaghi
ID: 16831751
I need to do the following:

display a temporary title
display the processing gif
do the business logic
redirect to the results page

I was thinking of doing this in the JSP

<%
     display a title (inactive field)
     display the gif
     flush the buffer, send the response to the client
     do the business logic
     redirect to the results page
%>

how could I redirect to the results page, if I do a redirect It might throw an exception?
0
 
LVL 8

Expert Comment

by:colr__
ID: 16831805
display a temporary title - this wont be possioble, once an HTML title  has been et, you cant change it as far as I know (Id check this with the javascript experts).
display the processing gif - create the image to display as normal, and hide it with javascript once it is to be removed, as per the above posts.
do the business logic - as normal
redirect to the results page - redirect as follows:

response.sendRedirect("resultspage.jsp");
return;

colr__
0
 
LVL 14

Assisted Solution

by:hoomanv
hoomanv earned 500 total points
ID: 16852013
I know you are looking for somthing like this
http://www.daveandal.net/books/6744/loadpost/simplewait.aspx
http://www.daveandal.net/books/6744/loadpost/progressbar.aspx
but it has been written in ASP, and I dont know how
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
This video teaches viewers about errors in exception handling.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month15 days, 9 hours left to enroll

581 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