This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Handling Threading Issue ???

 
fajju khan
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I am web developer, and i want to ask question about threading issue in jsp servlet application.
My first question is that, when i use MVC pattern and access Data Base in simple java classes (Command classes), then there is need of handling threading issue?

My second question is that, when i set object to session or request in java classes(Command Classes), there is need of handling thrading issue or not?
Also let me know the general tips about handling threading issues in jsp and servlet application.
Regards
Faisal Ishaque
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by fajju khan:
Hello
I am web developer, and i want to ask question about threading issue in jsp servlet application.
My first question is that, when i use MVC pattern and access Data Base in simple java classes (Command classes), then there is need of handling threading issue?

My second question is that, when i set object to session or request in java classes(Command Classes), there is need of handling thrading issue or not?
Also let me know the general tips about handling threading issues in jsp and servlet application.
Regards
Faisal Ishaque

Welcome to the Ranch, Faisal!!!
U have to aware of threadin issue in anywhere, when developing a web app... Of course, in response to ur first question, database access is really important to take account into the threading issue...
And also to your second question, there is a need to think about threading issue in session but not in request... Coz requests are thread-safe, except you make references of requests to instance variable...
As a conclusion, I just would like to suggest you to always keep in mind about the threading issue, when developing a web app, to avoid unexpected outcomes... Hope it helps....
 
fajju khan
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for reply ,
please tell me if i handle transaction level issue in DB (ACID), then still there is need of handling threading issue.
and what do you mean that REFERENCE TO REQUEST OBJECT?
regards
Faisal Ishaque
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by fajju khan:
and what do you mean that REFERENCE TO REQUEST OBJECT?

I mean if u have HttpServletRequest as instance variable declared outside _jspService method, then you make reference to that variable from HttpServletRequest object in the _jspService method... That reference becomes instance variable and not thread-safe at all... Even it might outcome unexpected result, if u do so...
 
fajju khan
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reply,
but one thing to mentioned that you did not answer my first part of second reply that if i handle transaction in DataBase, then the threading issue still remains or not?
best regards
Faisal Ishaque
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess you don't need to be worry about threading-issue in database access... But u do have to be worry about the variables' values to be inserted into the database... They may be modified, during the way to get into the database, if you do not handle well...
Hope it's clear...
 
fajju khan
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks again,
Now i get your point that if you declare instance variables or static variables then the threading issue occurs.
regards
Faisal
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic