• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

how to avoid synchronization problem in webpage

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 67750
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
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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67750
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

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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67750
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
Setting the isThreadSafe value will do nothing to solve such a problem.
 
eat bricks! HA! And here's another one! And a tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic