• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to avoid synchronization problem in webpage  RSS feed

 
Santhana Lakshmi.S
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
In my web page im facing a problem like if two user are workin, by that time one's page is getting reflected in other's page.
Can anyone tell me how to avoid this synchronization problem?
Thanx a lot
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Store values in request or session scope rather than in application scope or variables in the JSP/servlet?

What sort of values are having "synchronization problems"? How are these values being saved in your application?
 
Santhana Lakshmi.S
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
Thanx for ur reply.
After the user login im displaying a msg like
"Welcome,username"
At the time of testing one of my friend enters first with the same smile
after that i entered in my browser it is displaying Welcome smile!!!

Im storing the username in a session variable to track the current user in all the page.
can u tell me in detail to overcome this problem?
Thanx a lot in advance
 
Richard Green
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do you get this username variable out of the session?

do you use session.getAttribute() function?
[ June 19, 2006: Message edited by: Lynette Dawson ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Santhana Lakshmi.S and Lynett Dawson,

JavaRanch is a community of people from all over the world, many of who are not native English speakers. While using abbreviations like "u" instead of spelling out "you" is convenient when text messaging your friends on a cell phone or in a chat room, it presents an extra challenge to those that are already struggling with English. Additionally, such shortcuts may confound automated translation tools that patrons of the Ranch may be making use of.

I would like to ask for your help in making the content of JavaRanch a little easier to read for everybody that visits here by not using such abbreviations.

Please read this for more information.

thanks,
bear
JavaRanch Sheriff
 
Richard Green
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apologies. You mentioned this before and I have since tried to stop using abbreviations. But this one slipped the gate. Will correct it.

Just out of curiousity, do you have a custom UBBCode for these "warning" messages (or) do you type this message manually every time? (I administer few message boards (that uses vBulletin software) and have written few custom UBBCodes to make my life easy. Just thought of letting you know...)
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Lynette Dawson:
do you have a custom UBBCode for these "warning" messages


Cut-n-paste!
 
Santhana Lakshmi.S
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for using Abbreviations here.

In my jsp page i used session.setAttribute()and session.getAttribute() to set and get the current logged in user respectively.

And also i tried to use the following function after using application to set and get the current username.
synchronized(application){SharedObject foo = (SharedObject)application.getAttribute("username");
foo.update("newvalue");
application.setAttribute("username",newvalue);
}
but it is not working,Displaying some illegal start of expression errors
Can anyone tell me how to overcome this error

Thanks a lot
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
application != session

application scope - shared by all users; lives throughout the lifetime of the application

session scope - only used by one user; lives throughout the time that user is "active" in the application
 
Srilakshmi Vara
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try putting your username in session scope, same code should work.

or

You can synchronize the JSP using page directive attribute isThreadSafe="true|false"

First one is better than the Second one.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Setting the isThreadSafe value will do nothing to solve such a problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!