Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Synchronized problems in JSP/Servlet, please help me.

 
urey
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 might work, synchronizing the database access in the JSP would be a bad idea since I�d just create a queue of requests waiting to use the one Connection whereas I really need a number of Connections to deal with everyone simultaneously.
What I do? Need any advice from you.
Sincerely
Urey
 
Mapraputa Is
Leverager of our synergies
Sheriff
Posts: 10065
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your question is being answered here. Please, do not post the same question twice!
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not only that, but your name isn't compliant with the Javaranch naming policy. Please choose a name that meets the requirements.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic