PDA

View Full Version : How to refresh session attributes


madhoriya22
08-02-2007, 03:29 PM
:cool:

Hi,

I have set resource names(coming from database table resource) as session attribute and I am showing them in a drop down box in differenct JSP pages.
Now the problem is... suppose I updated the resource table and deleted one of the name from table...then how can I update the session attribute resource name at the same time in all JSP pages.

I am not using any scripting language.

Lallo
08-06-2007, 03:29 PM
Refresh all pages :)

hahaah i'm kidding!

But this is the logic. After you refresh the pages everything will be fine. So if you do the update often you can put META refresh on 15 seconds although this is not the best approach.

jkim
08-07-2007, 02:23 AM
I don't think you can achieve what you want without using any scripting languages.

Once data has been fed to the client, then whatever happens on the server is not reflected on the client-side. Because of the Pull architecture of HTTP, it's hard to achieve a push of data like you are trying to achieve. There are various methods of resolving this problem.

1. As the above poster said: refresh.
Refreshes the page every intermittant period.
Pro: Easy to code.
Con: This is a very ugly solution and drives user usability down the drain. of course, it can be done well so that it's *SOMEWHAT* usable, but it still sucks.

2. AJAX
Combines server code with client side scripting to achieve "push" or dynamic content generation.
Pro: If done right, nice looking, and minimal compatibility issues assuming end user has java script enabled.
Con: Security (java script enabled) or complexity issues.

3. Applet
Combines server code with client side applet.
Pro: Nice all round, most computers should have a JVM to handle the applet.
Con: Must have the applet signed (costs money). Rather slow.

4. ActiveX
Combines server code with client side activeX module.
Pro: Nice all round, most computers should have a VM to handle COM modules. Nice speed.
Con: Must have the active X signed (costs money), security risks in exposing clients to activeX unless configured correctly.

5. FlashText
Pro: Best solution in L&F and ease of use.
Con: All clients must have flash player 9+ (?) installed.

Lallo
08-09-2007, 10:58 PM
congrats jKim!!!!!
Nice explanation!!!!



Regards!

cash1981
08-10-2007, 01:40 PM
Did I understand you correctly if I presume you meant when you put an object in the session?

If you want to clear that session you can just say something like session.setAttribute("name",null);
and now it will get cleared.

If you need to update the session with the new values, you can just update the object (which is the pojo/bean that retrieves the information from the table)
session.setAttribute("name", Object);
now whenever a user opens the jsp, and you retrieve the object from the session it should get the correct information. I have done this method many times successfully.
But I suggest using tags instead, and writing these code in the application layer.