refresh all browsers in a session when a session attribute changes
Kevin Kiddy
Greenhorn
Joined: Mar 16, 2010
Posts: 2
posted
0
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
Bear Bibeault
Author and opinionated walrus
Marshal
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
This message was edited 1 time. Last update was at by Kevin Kiddy
subject: refresh all browsers in a session when a session attribute changes