File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes How to do Server pushing?  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "How to do Server pushing?  " Watch "How to do Server pushing?  " New topic

How to do Server pushing?

Gautam Ry
Ranch Hand

Joined: Dec 30, 2008
Posts: 41
I am working on a product that mainly tracks BPO daily activities.
Product based on 3 tiers Architecture (JSF,EJB2.0 and MSSQL).
There are many teams across the globe using this Application.
And their shift timings differ.

Say team A, the shift timing starts @ 2:30P.M (configurable) . Depending upon
the work load, they might need to log-on before 2:30P.M. In that case, that period
will be considered as over time.
My requirement is to display an message at 2:30 P.M. indicating that
their normal shift-timing starts by now.

That's the challenging part. In my understanding, I need to apply somekind of
server pushing concept.
Any better idea or approach?

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

You cannot push anything over HTTP, and therefore you cannot push over JSF. HTTP is based on a Request/Response cycle and there's no allowance for unsolicited responses or multiple responses for a request in the HTTP standard.

The best you can do in that regard is to poll the server periodically, which would be done either by adding a refresh meta-tag to the page or by having a client-side JavaScript process running to do AJAX requests. Of course, this only works when the page containing the meta-tag or JavaScript is actually being displayed in the browser. I suppose you could pop up a separate browser window for that purpose, even though as a general rule I don't like pop-up windows.

An IDE is no substitute for an Intelligent Developer.
Moin Yadageri

Joined: Jun 19, 2008
Posts: 10

I think it would be difficult to implement server push functionality as the server would have to send response to the client without the client actually making any request for it.

What you can do is, upon each employee login, you can check whether the login takes place before the actual shift start time or not, and if it does start before the actual time then you can calculate the difference in timing and send this timing difference back to the client browser, where you can have javascript code which waits for the time difference to elapse and then acts by firing up a popup window informing the user that the shift starts now.
Also you can make a request to the server when the pop up appears/user user clicks on the popup to do the required server side stuff.

~ Moin
Gerbrand van Dieijen
Ranch Hand

Joined: Nov 28, 2008
Posts: 30
Alternatively, you could use the a4j:poll tag. That tag will periodically poll the server, and can then update another a4j region or component. In this case, you could update the area that displays if a user is in his shift or not.

To prevent to many polls, you could set the interval to the total time the user has left before his shifts ends.

Sumeet Singh Aryan
Ranch Hand

Joined: Jul 30, 2008
Posts: 43
yes Gerbrand is right.... This helped me in my scenario, may be helpful in your scenario also. <a4j:poll> rocks in these type of scenarios

The woods are lovely, dark and deep, But I have promises to keep; And miles to go before I sleep, And miles to go before I sleep. - Robert Frost
I agree. Here's the link:
subject: How to do Server pushing?
It's not a secret anymore!