How to make servlet thread safe?

Answer Posted / sanjay

to make servlet as threas safe we have three approaches
1.do not instance variables into our servlet we use only
local variables
2.by using synchronized methods
3.synchronized blocks
above three ways synchronized blocks is the best way

Is This Answer Correct ?    12 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is servlet lazy loading?

691


What do you mean by scope object and what are its types?

563


What's the use of servletcontext?

677


When is the servlet instance created in the life cycle of servlet? What is the importance of configuring a servlet?

574


What is the use of send redirect () method?

586






What do you mean by servlet context?

599


What is the advantage of Servlets when compared with other server side technologies?

1853


If some new data has entered the database, explain how can a servlet refresh automatically?

733


What is http servlet? Explain with the help of an example.

578


What are all the protocols supported by httpservlet?

646


Hello, My project requirement is like I need to create a web page using MVC pattern. I hava a bean class, jsp page, servlet, service and dao. My jsp has two fields. One is dropdown list. The option values has to get populated from the database table. The other one is a text box and its value has to come from database table. As of now I have defined the fields in bean class, got the values from database using arraylists in dao class and I called this from service class. Can anyone please tell me the workflow of how the servlet will get this arraylist and populate the arraylist values as dropdown options in jsp page? Also I would like to know the role of bean class in MVC pattern? Thanks in advance!

1831


What is the life-cycle of servlets?

631


How do cookies work in servlets?

579


What is ServletConfig object?

606


What is the difference between servlet and jsp?

596