Two Laptop Bag*
The moose likes JSP and the fly likes Keeping user preferences for that page after periodic page refresh for multiple browsers / PC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Keeping user preferences for that page after periodic page refresh for multiple browsers / PC" Watch "Keeping user preferences for that page after periodic page refresh for multiple browsers / PC" New topic
Author

Keeping user preferences for that page after periodic page refresh for multiple browsers / PC

albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 245
I like to keep the user preferences for that JSP web page (e.g. the number of rows per table) after periodic page refresh.
The solution need to work for multiple browsers on the same or different PCs.
Please note that the user preferences (e.g. the number of rows per table) for different tabs (pages) on the same browser may be different.
URL Parameter Passing is the only approach I can think of.
e.g. http://127.0.0.1:8080/datadisplay?page=1&rowsperpage=20
Are there other approaches?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

Isn't that what databases are for?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 245
Bear Bibeault wrote:Isn't that what databases are for?


If database is used, then each browser tab (JSP page) within the same browser will be assigned an unique page id. The user preferences for that page will store in the database with the page id as key.
How to differentiate each browser tab (JSP page) from other tabs within the same browser so as to assign an unique page id for each browser tab?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

That's a data modeling issue that you'd need to solve.You could associated each distinct area that needs prefs by some unique name.
albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 245
Bear Bibeault wrote:That's a data modeling issue that you'd need to solve.You could associated each distinct area that needs prefs by some unique name.


How about this?
Every new JSP page is created with a hidden element which has an unique name (id). When this page is refreshed periodically by javascript, the hidden element will be submitted with this unique name.
The "database" can be implemented as JSP session at the server or as cookie at the client.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65



Why would it need to be periodically updated?
albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 245
Bear Bibeault wrote:

Why would it need to be periodically updated?


Polling a server database (which is updated by another process) to retrieve the latest data.
albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 245
I understand the pros and cons of using JSP session or cookie.
How is the URL Parameter Passing approach compare with either JSP session or cookie approach?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

How would that satisfy this requirement:
The solution need to work for multiple browsers on the same or different PCs.
?
albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 245
Bear Bibeault wrote:How would that satisfy this requirement:
The solution need to work for multiple browsers on the same or different PCs.
?



I don't know what is the problem - I think URL Parameter Passing can satisfy the requirement.
The same or different URL parameters can be passed to different tab or browser.
e.g.
IE tab 1: http://127.0.0.1:8080/datadisplay?page=1&rowsperpage=20
IE tab 2: http://127.0.0.1:8080/datadisplay?page=1&rowsperpage=10
Chrome tab 1: http://127.0.0.1:8080/datadisplay?page=2&rowsperpage=20
Chrome tab 2: http://127.0.0.1:8080/datadisplay?page=2&rowsperpage=15
albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 245
The following is my attempt to "Keeping user preferences for that page after periodic page refresh for multiple browsers / PC".
It is still work in progress and contains bugs.
I like to pass user input between two Controllers and display user input after submit.
The displayHw.jsp and displayHwController handles the user input.
It reads from the database and display the data.
It posts the write input to displayHwMgrController.
The displayHwMgrController writes to the database and redirects back to the displayHwController.
How to pass user input between two Controllers?
The user input disappear from the jsp page after the Apply button is clicked to submit the user input.
How to display the recently user input on the jsp page?
I am new to Spring 2.5.x and Prototype javascript library.
Please help.
Thanks.

displayHw.jsp


displayHwMgrController.java

displayHwController.java


 
jQuery in Action, 2nd edition
 
subject: Keeping user preferences for that page after periodic page refresh for multiple browsers / PC
 
Similar Threads
Fitting JSP page to print margins
Refresh in browser
How to display variant number of record each page based on user's request ?
How to display variant number of record each page based on user's request ?
input in a text box still appear after page refresh for IE but not FF, Chrome, Opera