Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Multiple users calling a static method via JSP  RSS feed

 
ashok khetan
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am checking if the logged on user is present in database using a static method. This method will be called by all jsp pages before showing any data.

I want to know - will there be any issues if multiple users are accessing various jsp pages and this method gets called simultaneously?

Thanks,
Ashok


 
N Sahni
Ranch Hand
Posts: 55
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since, there are no class memeber static variables hodling data. I don't see any concurrency issue here
 
Rohan Dhapodkar
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Till the point you mentioned about retrieving user name from session everything is perfect, but the way you are using database connection also matters.
1. If you are creating new DB connection inside checkUserId() function and releasing it then no issues.
2. above mentioned can be achieve using DB Connection pool which you will look up using JNDI.
3. But if you are created some static db connection in User class and reusing same coonection for query from checkUserId() function, then definitely it won't work. Connections should be thread safe.
 
Madhan Sundararajan Devaki
Ranch Hand
Posts: 312
Java MS IE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Data corruption will not occur as you may be executing only a Fetch/Select operation on the database. However, if the connections are not released properly, you might be inviting resource (memory/db connection/etc...) leakage issues.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!