• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how we can get notification of an event listener at web browser

 
pradeep singh
Ranch Hand
Posts: 339
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody
Can anybody tell me how we can get notification of an event listener at web browser( means notification display at web browser)?
 
Bobby Sharma
Ranch Hand
Posts: 598
3
Google App Engine jQuery Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please throw some more lights on your question.

by the way, did you mean HttpSessionListener?

I think HF has an example regarding this.

best regards,
omi
 
Garlapati Ravi
Ranch Hand
Posts: 171
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pradeep,
what type of event listener you mean ?
 
pradeep singh
Ranch Hand
Posts: 339
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Any event listener like HttpSessionAttributeListener,ContextAttributeListener etc. .But want to get notification on browser(means in a jsp page ) showing some message .Please explain with an example.
[ May 10, 2008: Message edited by: pradeep singh ]
 
Charles Lyons
Author
Ranch Hand
Posts: 836
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're asking what I think, you cannot do this with just Java because HTTP is a stateless protocol - so the connection between the server and the browser is lost once the request completes (typically a very short cycle).

If you need a page to be updated as soon as (or close enough to when) an event occurs, you need to use dynamic client-side scripting - e.g. JavaScript using the AJAX principles - and keep polling a servlet or other code on the server to determine when that event has fired. Once your JavaScript finds the right condition has occurred, it will then refresh your page or update its DOM accordingly.

Have I understood your question correctly?
 
Bobby Sharma
Ranch Hand
Posts: 598
3
Google App Engine jQuery Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Charles

Pradeep : why do you care to display the values on browser.If you are
preparing for exam then please don't bother because the exam does not go
that far.

but here is an example but it doesn't do what you want ,by the way.

//Dog class


//servlet



best regards,
omi

[ May 11, 2008: Message edited by: omi sharma ]
[ May 11, 2008: Message edited by: omi sharma ]
 
Charles Lyons
Author
Ranch Hand
Posts: 836
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why do you care to display the values on browser.
It's a good point - there is very little reason to propagate (the results of) container events to the browser as they probably don't model exactly what behaviour you'd want. There might be educational value in it, but it won't be tested on the exam nor will you probably ever use it in production.

I guess you're thinking about something like session timeout (and subsequent destruction) as "logging a user out"? Probably easiest not to bother showing your users this though until they click on another page and find they've been logged out, as typically happens with online banking. Also if you're not careful the process of checking the status of a session using AJAX principles will in fact reset the timeouts so your user's session never times out while they have at least one page open - which could be useful for maintaining relatively current "user online" counters I suppose.
 
pradeep singh
Ranch Hand
Posts: 339
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I am not asking this question for the exam point of view.I was asked this question in interview?
 
Paul Michael
Ranch Hand
Posts: 697
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Charles, the first solution I can think of for these kind of problems is to use AJAX (for polling events) and have some nice JavaScript display the message for you once they are available.
 
Bobby Sharma
Ranch Hand
Posts: 598
3
Google App Engine jQuery Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by pradeep singh:
Hi
I am not asking this question for the exam point of view.I was asked this question in interview?


Oh!,I see.By the way, some interviewers ask question which answer they
even don't know.

best regards,
omi
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic