Are servlets and JSPs threadsafe ? how can u make them threadsafe?

This question is related to Oracle Interview

Showing Answers 1 - 1 of 1 Answers

lucas

  • Nov 28th, 2005
 

You can make your JSPs thread-safe by having them implement the SingleThreadModel interface.

This is done by adding the directive

<%@ page isThreadSafe="false" %>

within your JSP page.

With this, instead of a single instance of the servlet generated for your JSP page loaded in memory, you will have N instances of the servlet loaded and initialized, with the service method of each instance effectively synchronized. You can typically control the number of instances (N) that are instantiated for all servlets implementing SingleThreadModel through the admin screen for your JSP engine.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions