• 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

Sending response to client with out receving request

 
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it possible to send a notification on the browser after user logged in for about 5 minutes, like "U have new e mail.". If we are working on servlet based HTTP request/response system.

The basic catch is how can track this 5 minute and send this notification , may be URL redirect or something else, note that we are doing that with receiving request from client.

Thanks
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A servlet can't push anything to the client without a request.

This is usually done by having the client make a request every n seconds. If you're using frames, you can have one of the frames do the polling via a meta-refresh tag. The frame can also be a hidden iframe so the page won't look like a framed website.

Alternately, look up the Javascript XMLHttpRequest object. This allows you to make an HTTP request from Javascript without refreshing the whole page.
[ May 03, 2005: Message edited by: Ben Souther ]
 
Mohan Karthick
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If we embbed a applet as a JMS client listener and on server side start a thread which will call a different method(logic of sending messgae to JMS provider after 5 minute) mean while servlet's service method will continue doing rest of the reguest response process. After 5 min when method send message to JMS provider it will be listened by client applet and will take some action or force user to do appropriate action by showing dialog box or some thing.
Is this architecture is good ?

Pls advice.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes we can use applet over a socket or JMS to achieve this kinda mechanism.
 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mohan Karthick:
If we embbed a applet as a JMS client listener and on server side start a thread which will call a different method(logic of sending messgae to JMS provider after 5 minute)

Is this architecture is good ?

Pls advice.



Overly complicated in my view.

There is no way to have a push under the given circumstances.

What you propose is only an overly complicated way to replace request-response with request-otherrequest-otherresponse-response

As mentioned before, if you want to implement the initial requirements you should go with the usual HTTP Redirect. It has its own flaws, but it works - even behind firewalls and proxies - something the applet thing certainly won't do without problems.

J.
 
Mohan Karthick
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


-----------------------------
As mentioned before, if you want to implement the initial requirements you should go with the usual HTTP Redirect. It has its own flaws, but it works - even behind firewalls and proxies - something the applet thing certainly won't do without problems.
-----------------------------------------------------
J



I have not understood what you suggested.
Suppose i am maintaing a simple session with user, and after 5 minutes of log in i want to send a message from server. That is only possible if on client side some client code is runing..so that is applet, becaue this 5 minutes cal calculation is from server side so I don't want to do it using java script.

Suppose he is browsing list of item and selected few items, mean while database get updated with two more item, now i want that user must refresh his page so that he can see the upadated items, but certainly wants to keep those item selected which user selected earlier.
 
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
there is a meta-refresh HTTP header, which when set, keeps refreshing the HTML page after the time specified in the header elapses. so you can set that header to keep refreshing after every 5 minutes.

This cant be a dynamic update


Suppose he is browsing list of item and selected few items, mean while database get updated with two more item, now i want that user must refresh his page so that he can see the upadated items, but certainly wants to keep those item selected which user selected earlier.



every time the page 'refreshes' it sends all the info to the servlet, which can send the checked items back as they are AND add the new items.
but, the client will get the updated list only AFTER the specified time has elapsed and the client has connected to the servlet again for new info.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Suppose he is browsing list of item and selected few items, mean while database get updated with two more item, now i want that user must refresh his page so that he can see the upadated items, but certainly wants to keep those item selected which user selected earlier.



You want to watch out not to annoy your customer when you do this.
If I were browsing products and in the process of adding something to a cart or in the middle of reading a paragraph describing one product and the page just refreshed itself, on it's own, causing me to loose my place, I might get frustrated and leave.
A popup or an icon that changes color (dare I say blinks) to indicate that there is more information availible for this page might be more palataable.
 
Mohan Karthick
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok Ben your right, well i didn't exactly mean to refresh the page all of sudden. My point is how can I tell client, like some thing happened at server for example it could be notification for mail !!

Neraj thanks for your input but i don't want to control it from client side because i am not sure whether the update at DB is every 5 minute or in 48 hours, basic thing is when ever some update happens on server then only I want to notify my client.(using servlet/JSP)

So my conclusion is Applet JMS provider is best solutions, pls let me know the flaw of my solution.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree that the applet is probably a heavy handed approach to this.
You'll have to consider what to do for people who don't have the Java plugin to run it.

A polling frame or a Javascript function that checks with the server every n seconds via the XMLHttpRequest control would seem to be a lot easier and robust to me -- especially for a public, internet site.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, as Jeffery has mentioned.
Relying on communication through any ports other than 80 and 443 leaves you open to firewall issues -- both on the server and the client side.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

i don't want to control it from client side because i am not sure whether the update at DB is every 5 minute or in 48 hours


You should rethink that requirement - it will be MUCH simpler to have the client side do a request every X seconds to see if there is anything new. On the server side your architecture should be organized around making it quick to determine if this user has any new data.
Either an applet or JavaScript can be used, I would lean toward JavaScript - in either case it does NOT have to redo the page in order to show that new information is available. Just change the contents of a single element of the page.
Bill
 
Mohan Karthick
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am really thankful to all of your for your inputs.

Suppose instead of applet I use jsp include tag and put it at the bottom for notification purpose, now this jsp at the footer actually open a connection to JMS provider/ observer pattern and listening it, when ever JMS provider recv a notificationits update all JMS client(JSP include JSP file) listen it take for respected action, this way client can see the action which he needs to do.

What about this ? well I am avoiding java script for any purpose because i noticed that the developmwnt time increases and need to test it very extensively becaue java script error is really very irritating, and we are expecting that client browser is going to be in variation.

We use to give stress on all server side control.
 
Neeraj Dheer
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you think debugging javascript is annoying, how do you expect to debug/test JMS?

the functionality that we are talking about here is very basic and will be supported by most browsers available today.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mohan Karthick:
I am really thankful to all of your for your inputs.

Suppose instead of applet I use jsp include tag and put it at the bottom for notification purpose, now this jsp at the footer actually open a connection to JMS provider/ observer pattern and listening it, when ever JMS provider recv a notificationits update all JMS client(JSP include JSP file) listen it take for respected action, this way client can see the action which he needs to do.

What about this ? well I am avoiding java script for any purpose because i noticed that the developmwnt time increases and need to test it very extensively becaue java script error is really very irritating, and we are expecting that client browser is going to be in variation.
We use to give stress on all server side control.



JSP is server side, whether it's in an include tag or not.
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Suppose instead of applet I use jsp include tag and put it at the bottom for notification purpose, now this jsp at the footer...


You have GOT to stop thinking in terms of JSP.
JSP just creates an HTML page - possibly with an applet or JavaScript but still HTML.
When I have done this sort of thing, I have started with plain HTML as a mockup of the final product. Solve one problem at a time. When you have a functioning plain HTML prototype, THEN figure out how to create a dynamic version with JSP.
I recommend the Firefox browser for developing/debugging JavaScript - the developer tools are excellent - I love being able to browse around the actual HTML DOM and change values.
Bill
 
reply
    Bookmark Topic Watch Topic
  • New Topic