• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can ajax be used to know background processing?

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have to create a application using struts whose job is to generate reports at the server side based on the user inputs.

However there is a requirement that whatever processing is done at the server side should be informed to the user in the browser at the same time.

For example: If server is generating 5 reports then user should be informed that:
- 1st report is being generated.
- 1st report completed
- 2nd report is being generated.
....
and after generating all the 5 reports, the response should be sent to the user.

Question:
- Is it possible to implement the above requirement using ajax?
- Has anyone implemented such kind of feature and if yes how?

Any help or suggestion are welcome

Thanks.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, Ajax does not enable you to push content from the server to the client without a client request. It can be used to poll back to the server now and again to check status, and there are products that will maintain an open connection (expensive).

Typically, web apps with this kind of functionaity have a status page that users can visit to view the status of background operations.
[ August 31, 2007: Message edited by: Bear Bibeault ]
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've done this kind of push to the client with a client-side applet holding an open ServerSocket. The server has to know the client ip and port, stored on the session. To send a status update the server does connect-send-disconnect. We had the advantage (?) of an outer frame with all GUI work done in a IFrames, so the applet on the outer frame could be active all day long. The whole thing would be easily broken by leaving the page otherwise.
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What about using Comet for this ?
http://en.wikipedia.org/wiki/Comet_(programming)
http://martin.ankerl.com/2007/08/21/ajax-dojo-comet-tutorial/
 
Sahil Saxena
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To [Bear Bibeault]


Typically, web apps with this kind of functionality have a status page that users can visit to view the status of background operations.



Query: Do we maintain the status of background operation in DB and
on status page we display the status by fetching it from DB???

To [Stan James]
Query
Can the functionality which you did in your application using applet can be done using struts web application? For e.g. there will be 2 frames on a single page. one frame will contain form and the other frame will contain the status of the back ground processing. The 2 nd frame may get refresh after particular time say 2 secs which will send query to the server for status of background processing and display it. Or is there any other way which you would like to suggest? I am not aware whether the frames solution will be feasible or not?

To [Valentin Crettaz]
Query
I was bit aware of COMET however dont know how to apply it to my web application scenario.
I will read the tutorial "http://martin.ankerl.com/2007/08/21/ajax-dojo-comet-tutorial/" and see if I can get any hint from it .
If you have any suggestion, how to apply COMET to my web application pls let me know


Thanks to everyone
[ September 03, 2007: Message edited by: Sahil Saxena ]
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think Struts or not Struts is not important here. Should work with frames that are populated by Struts based pages.

For our applet use, the main page has the applet tags and no visible content. All other application content is in frames. The main page is really necessary only to hold the applet so it can keep its server socket open all day.

When the server pushes a message to the applet, the applet invokes JavaScript on the main page. We have a publish-subscribe setup, so frames that want to accept messages can register to receive them. The main page publishes the message to all interested frames.

One advantage over the COMET scheme is that the server is not burdened with a lot of connections from the client. The disadvantage is that the server has to keep track of addresses of active browsers and do a full connect send disconnect conversation. We have the potential for sending a message to all logged on users which might number in the thousands which might take a long time to send.
[ September 04, 2007: Message edited by: Stan James ]
 
What a show! What atmosphere! What fun! What a tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic