• 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

refresh all browsers in a session when a session attribute changes

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a servlet (called "mainServlet") that calls another servlet ("GetList") that I intend to use as a "dialog" as a list chooser by a JavaScript button onClick as with:



The servlet "GetList" allows the user to choose from a list and on the "OK" button JavaScript onClick calls a servlet named "PutListParametersServlet" and closes the "GetList" browser (window).

"PutListParametersServlet" sets a session attribute and I have a HttpSessionAttributeListener that gets the attributeReplaced correctly called. All I describe so far works correctly.

My intention is to have the original (or first) servlet ("mainServlet") refresh (or redraw) when the session attribute changes. I figured that I could do this from the HttpSessionAttributeListener but I cannot figure it out. The only way I can do this is to have this line in "mainServlet":



which causes a refresh each 5 seconds and then "mainServlet" can refresh after the session attribute change. I suppose I could put logic around a "smart" 5 second refresh but that doesn't seem correct.

What do I need to do to cause all browsers in a session to refresh when a session attribute changes?

Also, I recently passed SCJP and am working on SCJD and studying for SCWCD so am trying to avoid using ajax, extjs, spring, dojo, flash, etc. I have enjoy reading many of the JavaRanch forums. Generally, when I ask a question like this to other developers they say that I'm crazy to not use those other tools.

Thanks for your help,

Kevin
 
Sheriff
Posts: 67747
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

Kevin Kiddy wrote:What do I need to do to cause all browsers in a session to refresh when a session attribute changes?

You can't. From a listener how could you possibly know who is still browsing your app, and who's gone off to look at videos on YouTube?

Why not just return a JavaScript response that causes the parent to refresh?

Also, I recently passed SCJP and am working on SCJD and studying for SCWCD so am trying to avoid using ajax

Huh? Really? What do certifications have to do with using Ajax or JavaScript libraries?

they say that I'm crazy to not use those other tools.

I agree. the tools are there to be used. Re-inventing the wheel all the time is a very novice attitude.
 
Kevin Kiddy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't find a reference to a "JavaScript response that causes the parent to refresh" that is generated by the new window from the "open.window". I think it should be possible since it is basically what the javascript "prompt" function does by returning the text field value - I just need the dialog to be a list instead of a text field. Can you point me in the right direction?

From my perspective, when I'm trying to learn web programming it seems especially confusing when there are many tools/technologies (ie ajax, extjs, flex, dojo, spring, etc) that can accomplish the same task. I assume that most of these tools are a wrapper to servlets that hide some soft of servlet complexity. Also, I assume that every 6 or 12 months new tools will be better then the current. Therefore, it seems reasonable to avoid these tools to learn servlet fundamentals esp. when preparing for SCWCD. I think in the beginning of "Head First: Servlets" the authors say to avoid using Eclipse when studying for SCWCD because Eclipse will hide some servlet complexity and then you will not understand the basics of servlets. What do you think? (I'm esp. interested in the opinion of an experienced web programmer.)

Thanks,

Kevin
 
reply
    Bookmark Topic Watch Topic
  • New Topic