Link to home
Start Free TrialLog in
Avatar of inzaghi
inzaghi

asked on

JSP Processing

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
ASKER CERTIFIED SOLUTION
Avatar of colr__
colr__

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CEHJ
You coudl use an applet
Avatar of inzaghi
inzaghi

ASKER

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.

Avatar of inzaghi

ASKER

Come on experts need your help big time.
Avatar of inzaghi

ASKER

<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
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Avatar of inzaghi

ASKER

cant I use the onload method of the form?
onload only works in the body tag, since its the page that loads as opposed to the form itself.

colr__
>> 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.
Avatar of inzaghi

ASKER

I only want to display the gif uptil the point the jsp page starts to render its display values to the user
Avatar of inzaghi

ASKER

similar to any sites such as lastminute.com
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__
Avatar of inzaghi

ASKER

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?
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__
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial