synchronized « Thread « JSP-Servlet Q&A

1. Java: A synchronized method is accessed several times by reflection?

I've a very odd behaviour on one of my class, and don't know exactly what is happening. 1) I've a JSP which sends a request to a Servlet with AJAX 2) The servlet ...

2. synchronized in servlets

3. synchronized problems in JSP/Sverlet, please help!

There isn't a new instance of the Servlet/JSP for each request in Tomcat - they are probably all calling the same instance so any state will be shared. If I Connection is stored as a member variable then I'll have synchronized problems with it already being in use if two people hit the page at the same time. Incidentally, although it ...

4. Does synchronized works in a servlet init function?

Hi, Welcome to JavaRanch! There's no special magic in init(); synchronization works the same there as it does everywhere else. Can you describe in somewhat more detail what you did, what you expected to happen, and what happened instead, being as specific as possible and avoiding the confusing word "it" in favor of using the names of things?