<?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, 03 Feb 2012 10:23:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.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>June 17, 2008 -- <a href="http://www.bestjavainterviewquestions.com/awt-interview-questions-3/" title="AWT Interview Questions">AWT Interview Questions</a> (0)</li><li>August 24, 2008 -- <a href="http://www.bestjavainterviewquestions.com/define-servletoutputstream-object-in-jsp/" title="Define ServletOutputStream object in Jsp">Define ServletOutputStream object in Jsp</a> (0)</li><li>February 15, 2009 -- <a href="http://www.bestjavainterviewquestions.com/define-ejb-frame-work/" title="Define EJB frame work">Define EJB frame work</a> (1)</li><li>November 6, 2008 -- <a href="http://www.bestjavainterviewquestions.com/load-factor/" title="Load Factor">Load Factor</a> (0)</li><li>June 23, 2008 -- <a href="http://www.bestjavainterviewquestions.com/java-util-package-2/" title="JAVA UTIL PACKAGE">JAVA UTIL PACKAGE</a> (0)</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>

