• Post Reply Bookmark Topic Watch Topic
  • New Topic

Show animation during report building

 
surya naidu
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JSP which sends a request to a servlet to generate a memory intensive report then the request is forwarded to a JSP using request Dispatcher

I wanted to display a GIF (Some kind of a rotating thing) which shows the report is being generated

I tried to display a message onload....But the control wouldnt go to the JSP till the whole report is generated

I also tried this approach which someone suggested in a previous thread but the Image stays static and wont move at all

if ( session.getValue( "waitPage" ) == null ) {
System.out.println("In session no t null check going on");
session.putValue( "waitPage", Boolean.TRUE );
out.println( "<html><head>" );
out.println( "<title>Please Wait...</title>" );
out.println( "<meta http-equiv=\"Refresh\" content=\"0\" >" );
out.println( "</head><body>" );
out.println( "<br><br><br>" );
out.println( "<center><h3>Report being Processed.<br>" );
out.println( "Please wait...</h3></center>" );
out.println( "<div id='logo'><center><img src='../images/loading-gif-animation.gif' />" );
out.println( "</center></div>" );
out.close();
session.setAttribute("loopBreaker","test");
}

I also increased the content value to something greater than 1 to refresh it
I that case the image moves but the report doesnt get executed till the time specified in content....


Can some on help me please


Thank you
 
Tarun Bolla
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Try the above code and you should get an idea...you could stretch the div or just put an image or what ever you think is fit..
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All of these approaches using server-side code are doomed to failure. While the browser is busy sending a request and receiving a new page, it's not going to show any animations.

If you really want to do this, you'll need to employ Ajax so that the browser can stay active while the request is transpiring behind the scenes.
 
surya naidu
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tarun thank you for the suggestion.......but it didnt work for me

Bear Bibeault In my case i am actually using a new window to show the result....So how do i even use AJAX without the control going to the window which is opened???


Thank you

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Display a page in the new window that shows the animation, which then submits the long request as Ajax.
 
surya naidu
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The data I am trying to display has got like some 84 columns and more than 8000 rows......Do you think this would be efficient enough..??

I could get the entire data into an XML and send it to the JSP........!!! but I need to iterate through it and show it an table which uses display tag.....!!!

Do you think the process would be efficient and how could i get the data to a display table......if i succeed in getting it to the JSP in the form of a XML


Appreciate your help
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would never send that much data. I would use paging and allow the user to filter the data.

And why are you sending XML to the client? Why not just format the table in JSP and send that. XML seems like a needless and expensive middle-man.
 
surya naidu
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May be i am lacking some knowledge with AJAX here...

""Why not just format the table in JSP and send that. XML seems like a needless and expensive middle-man.""

can you throw some more light on to this statement
The only knowledge i have of AJAX is ....from the JSP create a new request to a servlet....... get required data.....alias it to a class(Bean).....form an XML
using Xstream API......get it on to the JSP parse it by tag name and use data on JSP

But as you said how can i format the table in JSp without sending the XML on the scripting side???
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Despite its name, Ajax is not limited to sending XML. It can be used to return any text format, including HTML fragments created by a JSP. This fragment can just be added to the DOM without having to parse XML on the client (which is a royal pain in the keester).

If you are going to use Ajax, I highly recommend using a JavaScript library such as jQuery to do it for you. Otherwise, it's a real mess.
 
surya naidu
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much mr Bibeault for the explaination.I think i need to upgrade my knowldge on AJAX and Jquery here

Is there any weblink you can suggest me to return data from ajax to HTML fragments by a JSP directly.......or that would be helpful for me to break this up
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look for examples that use jQuery's .load() method. It's the simplest way I know of to load HTML fragments into the DOM via Ajax.

An example: $('#someElement').load('/some/url');

This hits the specified URL, and injects the fragment returned as the response into the wrapped DOM element. It doesn't get easier than that.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!