Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Handling Threading Issue ???

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Is this the real life? Is this just fantasy? Is this a tiny ad?
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic