File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Handling Threading Issue ??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Handling Threading Issue ???" Watch "Handling Threading Issue ???" New topic
Author

Handling Threading Issue ???

fajju khan
Greenhorn

Joined: Jan 28, 2004
Posts: 5
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

Joined: Jun 08, 2002
Posts: 3178
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....


Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
fajju khan
Greenhorn

Joined: Jan 28, 2004
Posts: 5
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

Joined: Jun 08, 2002
Posts: 3178
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

Joined: Jan 28, 2004
Posts: 5
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

Joined: Jun 08, 2002
Posts: 3178
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

Joined: Jan 28, 2004
Posts: 5
thanks again,
Now i get your point that if you declare instance variables or static variables then the threading issue occurs.
regards
Faisal
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Handling Threading Issue ???