<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Java Interview Questions &#187; Using the Thread-Safe in Jsp</title>
	<atom:link href="http://www.bestjavainterviewquestions.com/category/using-the-thread-safe-in-jsp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bestjavainterviewquestions.com</link>
	<description>Java Interview Questions &#124; Core Java Interview Questions &#124; Advanced Java Interview Questions &#124; EJB Interview Questions &#124; J2EE Interview Questions &#124; Hibernate Interview Questions</description>
	<lastBuildDate>Fri, 30 Jul 2010 06:00:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Explain Thread-Safe JSP page and there advantages</title>
		<link>http://www.bestjavainterviewquestions.com/explain-thread-safe-jsp-page-and-there-advantages/</link>
		<comments>http://www.bestjavainterviewquestions.com/explain-thread-safe-jsp-page-and-there-advantages/#comments</comments>
		<pubDate>Tue, 30 Sep 2008 16:14:58 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[Using the Thread-Safe in Jsp]]></category>
		<category><![CDATA[thread-safe jsp page]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=389</guid>
		<description><![CDATA[Q) How can I implement a thread-safe JSP page? What are the Advantages and Disadvantages of using it? A) You can make your JSPs thread-safe by having them implement the SingleThreadModel interface. This is done by adding the directive &#60;%@ page isThreadSafe=&#8221;false&#8221; %&#62; within your JSP page. With this, instead of a single instance of [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Q) How can I implement a thread-safe JSP page? What are the Advantages and Disadvantages of using it?</strong></p>
<p><strong>A)</strong> You can make your JSPs thread-safe by having them implement the SingleThreadModel interface. This is done by adding the directive</p>
<p><strong> &lt;%@ page isThreadSafe=&#8221;false&#8221; %&gt; </strong>within your JSP page.</p>
<p>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.<br />
More importantly, avoid using the <strong>&lt;%! DECLARE %&gt;</strong> tag for variables. If you do use this tag, then you should set <strong><em>isThreadSafe to true</em></strong>, as mentioned above. Otherwise, all requests to that page will access those variables, causing a nasty race condition.<br />
<strong><em>SingleThreadModel</em></strong> is not recommended for normal use. There are many pitfalls, including the example above of not being able to use <strong>&lt;%! %&gt;</strong>. You should try really hard to make them thread-safe the old fashioned way: by making them thread-safe</p>
<h2  class="related_post_title">Random Posts</h2><ul class="related_post"><li><a href="http://www.bestjavainterviewquestions.com/awt-interview-questions-2/" title="AWT Interview Questions"><img src="Array" alt="AWT Interview Questions" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/can-we-provide-a-constructor-in-the-servlet-class/" title="Can we provide a constructor in the servlet class"><img src="Array" alt="Can we provide a constructor in the servlet class" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/jsp-interview-questions-2/" title="JSP Interview Questions"><img src="Array" alt="JSP Interview Questions" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/ejb-interview-questions-2/" title="EJB Interview questions"><img src="Array" alt="EJB Interview questions" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/making-a-frame-non-resizable-in-java/" title="Making a Frame Non-Resizable in Java "><img src="Array" alt="Making a Frame Non-Resizable in Java " /></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/explain-thread-safe-jsp-page-and-there-advantages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
