<?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; Session Tutorials</title>
	<atom:link href="http://www.bestjavainterviewquestions.com/category/java-important-notes/session-tutorials/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>Define Session Hijacking</title>
		<link>http://www.bestjavainterviewquestions.com/define-session-hijacking-2/</link>
		<comments>http://www.bestjavainterviewquestions.com/define-session-hijacking-2/#comments</comments>
		<pubDate>Sat, 20 Sep 2008 17:18:10 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[Session Tutorials]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=264</guid>
		<description><![CDATA[Question: What is session hijacking? Answer: If you application is not very secure then it is possible to get the access of system after acquiring or generating the authentication information. Session hijacking refers to the act of taking control of a user session after successfully obtaining or generating an authentication session ID. It involves an [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Question: What is session hijacking?<br />
Answer:</strong> If you application is not very secure then it is possible to get the access of system after acquiring or generating the authentication information. Session hijacking refers to the act of taking control of a user session after successfully obtaining or generating an authentication session ID. It involves an attacker using captured, brute forced or reverse-engineered session IDs to get a control of a legitimate user&#8217;s Web application session while that session is still in progress.</p>
<h2  class="related_post_title">Random Posts</h2><ul class="related_post"><li>July 7, 2008 -- <a href="http://www.bestjavainterviewquestions.com/struts-interview-questions/" title="STRUTS Interview Questions">STRUTS Interview Questions</a> (0)</li><li>June 23, 2008 -- <a href="http://www.bestjavainterviewquestions.com/19/" title="Java Basic Questions">Java Basic Questions</a> (1)</li><li>July 7, 2008 -- <a href="http://www.bestjavainterviewquestions.com/jsp-standard-questions/" title="JSP Standard Questions">JSP Standard Questions</a> (0)</li><li>July 7, 2008 -- <a href="http://www.bestjavainterviewquestions.com/jsp-interview-questions-2/" title="JSP Interview Questions">JSP Interview Questions</a> (1)</li><li>August 15, 2008 -- <a href="http://www.bestjavainterviewquestions.com/thread-example-for-runnable-interface/" title="Thread example for Runnable Interface">Thread example for Runnable Interface</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/define-session-hijacking-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Session Tracking Example using Servlets</title>
		<link>http://www.bestjavainterviewquestions.com/session-tracking-example-using-servlets/</link>
		<comments>http://www.bestjavainterviewquestions.com/session-tracking-example-using-servlets/#comments</comments>
		<pubDate>Mon, 08 Sep 2008 18:29:17 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[Session Tutorials]]></category>
		<category><![CDATA[session servlet example]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=299</guid>
		<description><![CDATA[Sessions in Servlets The following examples show the newer session tracking API in use within Servlets. The first time a user runs the &#8220;Barman&#8221; servlet, it sets up a session for him and prompts for his name. On subsequent visits, it addresses him by name straight away, and also keeps a tally of how many [...]]]></description>
			<content:encoded><![CDATA[<p><strong><br />
<h3>Sessions in Servlets</h3>
<p></strong></p>
<p>The following examples show the newer session tracking API in use within Servlets.</p>
<p>The first time a user runs the &#8220;Barman&#8221; servlet, it sets up a session for him and prompts for his name. On subsequent visits, it addresses him by name straight away, and also keeps a tally of how many times he&#8217;s visited.</p>
<p>The &#8220;Landlord&#8221; servlet does the same as the Barman, but in addition it maintains a static vector of sessions so that it can (and does ; &#8211; ) ) report on everyone in the bar and how much they&#8217;ve had to drink.</p>
<p>Note &#8211; &#8220;Barman&#8221; keeps the users apart, which is typically what you would do with a shopping cart &#8230; &#8220;Landlord&#8221; provides a management information service too &#8230;.<br />
<strong></p>
<h3>::::::::::::::<br />
Barman.java<br />
::::::::::::::</h3>
<p>import java.io.*;<br />
import java.text.*;<br />
import java.util.*;<br />
import javax.servlet.*;<br />
import javax.servlet.http.*;</p>
<p>/**<br />
 * Simple Session Tracking<br />
 */</p>
<p>public class Barman extends HttpServlet {</p>
<p>    public void doGet(HttpServletRequest request,<br />
                      HttpServletResponse response)<br />
        throws IOException, ServletException<br />
    {</p>
<p> HttpSession session = request.getSession(true);<br />
 Integer count = (Integer)session.getAttribute(&#8220;mycounter&#8221;);<br />
        response.setContentType(&#8220;text/html&#8221;);<br />
        PrintWriter out = response.getWriter();<br />
        out.println(&#8221; < html > &#8220;);<br />
        out.println(&#8221; < body bgcolor=\"white\" > &#8220;);</p>
<p> if (count == null) {<br />
  count = new Integer(0);<br />
  out.print(&#8221; < h1 >Welcome. Please enter your name< / h1 >&#8220;);<br />
  out.print(&#8221; < form action=/nan/servlet/Barman > &#8220;);<br />
  out.print(&#8221; < input name=whoyouare > &#8220;);<br />
  out.print(&#8221; < / form > &#8220;);<br />
 } else {<br />
  String wanted = request.getParameter(&#8220;whoyouare&#8221;);<br />
  if (wanted != null) {<br />
   session.setAttribute(&#8220;who&#8221;,wanted);<br />
  } else {<br />
   wanted = (String)session.getAttribute(&#8220;who&#8221;);<br />
  }<br />
  count = new Integer(count.intValue() + 1);<br />
  out.print(&#8221; < h1 > Welcome back &#8220;+wanted+&#8221;< / h1 > &#8220;);<br />
  out.println(&#8220;This is your visit no. &#8220;+count+&#8221;< BR >&#8220;);<br />
 }<br />
 session.setAttribute(&#8220;mycounter&#8221;,count);<br />
        out.println(&#8221; < / body > &#8220;);<br />
        out.println(&#8221; < / html > &#8220;);<br />
    }<br />
}</strong></p>
<p><strong>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</strong><br />
<strong></p>
<h3>::::::::::::::<br />
Landlord.java<br />
::::::::::::::</h3>
<p>import java.io.*;<br />
import java.text.*;<br />
import java.util.*;<br />
import javax.servlet.*;<br />
import javax.servlet.http.*;</p>
<p>/**<br />
 * Simple Session Tracking<br />
 * Also reports on all users<br />
 */</p>
<p>public class Landlord extends HttpServlet {</p>
<p>public static Vector People;</p>
<p>public void init(ServletConfig cc) throws ServletException {<br />
 super.init(cc);<br />
 People = new Vector();<br />
 }</p>
<p>    public void doGet(HttpServletRequest request,<br />
                      HttpServletResponse response)<br />
        throws IOException, ServletException<br />
    {</p>
<p> HttpSession session = request.getSession(true);<br />
 Integer count = (Integer)session.getAttribute(&#8220;mycounter&#8221;);<br />
        response.setContentType(&#8220;text/html&#8221;);<br />
        PrintWriter out = response.getWriter();<br />
        out.println(&#8221; < html > &#8220;);<br />
        out.println(&#8221; < body bgcolor=\"white\" > &#8220;);</p>
<p> if (count == null) {<br />
  count = new Integer(0);<br />
  out.print(&#8220;< h1 >Welcome. Please enter your name< / h1 >&#8220;);<br />
  out.print(&#8221; < form action=/nan/servlet/Landlord > &#8220;);<br />
  out.print(&#8221; < input name=whoyouare > &#8220;);<br />
  out.print(&#8221; < / form > &#8220;);<br />
  People.addElement(session);<br />
 } else {<br />
  String wanted = request.getParameter(&#8220;whoyouare&#8221;);<br />
  if (wanted != null) {<br />
   session.setAttribute(&#8220;who&#8221;,wanted);<br />
  } else {<br />
   wanted = (String)session.getAttribute(&#8220;who&#8221;);<br />
  }<br />
  count = new Integer(count.intValue() + 1);<br />
  out.print(&#8221; < h 1 >Welcome back &#8220;+wanted+&#8221;< / h1 > &#8220;);<br />
  out.println(&#8220;This is your visit no. &#8220;+count+&#8221;< BR >&#8220;);<br />
  out.println(&#8220;< BR >< H2 >Those here present &#8230;< / h2 >&#8220;);</p>
<p>  for (int i=0; i
<people.size();i++) {<br />
   HttpSession present = (HttpSession)(People.elementAt(i));<br />
   String ere = (String)present.getAttribute("who");<br />
   out.print(ere+ " is here and has drunk ");<br />
   int ii = ((Integer)present.getAttribute("mycounter")).intValue();<br />
   out.print("" + ii + " previously< BR >&#8220;);<br />
   }<br />
 }<br />
 session.setAttribute(&#8220;mycounter&#8221;,count);<br />
        out.println(&#8221; < /body > &#8220;);<br />
        out.println(&#8221; < /  html > &#8220;);<br />
    }<br />
}</strong></p>
<h2  class="related_post_title">Random Posts</h2><ul class="related_post"><li>August 10, 2008 -- <a href="http://www.bestjavainterviewquestions.com/example-programs-of-lifecycle-of-servlets/" title="Example programs of lifecycle of servlets">Example programs of lifecycle of servlets</a> (0)</li><li>July 7, 2008 -- <a href="http://www.bestjavainterviewquestions.com/jsp-interview-questions-2/" title="JSP Interview Questions">JSP Interview Questions</a> (1)</li><li>September 20, 2008 -- <a href="http://www.bestjavainterviewquestions.com/define-session-hijacking-2/" title="Define Session Hijacking">Define Session Hijacking</a> (0)</li><li>September 17, 2008 -- <a href="http://www.bestjavainterviewquestions.com/using-mysql-database-in-hibernate/" title="Using MySql DataBase in Hibernate">Using MySql DataBase in Hibernate</a> (0)</li><li>April 6, 2009 -- <a href="http://www.bestjavainterviewquestions.com/exception-handling-and-their-uses/" title="Exception Handling and their uses">Exception Handling and their uses</a> (2)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/session-tracking-example-using-servlets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Servlets Session Examples</title>
		<link>http://www.bestjavainterviewquestions.com/servlet-session-examples/</link>
		<comments>http://www.bestjavainterviewquestions.com/servlet-session-examples/#comments</comments>
		<pubDate>Mon, 08 Sep 2008 18:19:35 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[Session Tutorials]]></category>
		<category><![CDATA[session example]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=294</guid>
		<description><![CDATA[Servlet Session Example /* * Copyright 2004 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the &#8220;License&#8221;); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Servlet Session Example</strong></p>
<p>/*<br />
 * Copyright 2004 The Apache Software Foundation<br />
 *<br />
 * Licensed under the Apache License, Version 2.0 (the &#8220;License&#8221;);<br />
 * you may not use this file except in compliance with the License.<br />
 * You may obtain a copy of the License at<br />
 *<br />
 *     http://www.apache.org/licenses/LICENSE-2.0<br />
 *<br />
 * Unless required by applicable law or agreed to in writing, software<br />
 * distributed under the License is distributed on an &#8220;AS IS&#8221; BASIS,<br />
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<br />
 * See the License for the specific language governing permissions and<br />
 * limitations under the License.<br />
 */<br />
/* $Id: SessionExample.java,v 1.4 2004/03/18 16:40:33 jfarcand Exp $<br />
 *<br />
 */</p>
<p>import java.io.*;<br />
import java.text.*;<br />
import java.util.*;<br />
import javax.servlet.*;<br />
import javax.servlet.http.*;</p>
<p>/**<br />
 * Example servlet showing request headers<br />
 *<br />
 * @author James Duncan Davidson <duncan@eng.sun.com><br />
 */</p>
<p>public class SessionExample extends HttpServlet {</p>
<p>  ResourceBundle rb = ResourceBundle.getBundle(&#8220;LocalStrings&#8221;);</p>
<p>  public void doGet(HttpServletRequest request, HttpServletResponse response)<br />
      throws IOException, ServletException {<br />
    response.setContentType(&#8220;text/html&#8221;);</p>
<p>    PrintWriter out = response.getWriter();<br />
    out.println(&#8221; < html > &#8220;);<br />
    out.println(&#8221; < body bgcolor=\"white\" > &#8220;);<br />
    out.println(&#8220;< head >&#8220;);</p>
<p>    String title = rb.getString(&#8220;sessions.title&#8221;);<br />
    out.println(&#8221; < title > &#8221; + title + &#8220;< /title >&#8220;);<br />
    out.println(&#8221; < / head > &#8220;);<br />
    out.println(&#8221; < / body > &#8220;);</p>
<p>    // img stuff not req&#8217;d for source code html showing<br />
    // relative links everywhere!</p>
<p>    // XXX<br />
    // making these absolute till we work out the<br />
    // addition of a PathInfo issue</p>
<p>    out.println(&#8220;< a  href=\"../sessions.html\"  >&#8220;);<br />
    out.println(&#8221; < img src=" ../images/code.gif\" height=24  "<br />
        + "width=24 align=right border=0 alt=\"view code\ " > < / a >&#8220;);<br />
    out.println(&#8220;<  a href=\"../index.html\"   >&#8220;);<br />
    out.println(&#8220;<  img src=\"../images/return.gif\" height=24 "<br />
        + "width=24 align=right border=0 alt=\"return\" >< / a >&#8220;);</p>
<p>    out.println(&#8220;< h3 >&#8221; + title + &#8220;< / h3 > &#8220;);</p>
<p>    HttpSession session = request.getSession(true);<br />
    out.println(rb.getString(&#8220;sessions.id&#8221;) + &#8221; &#8221; + session.getId());<br />
    out.println(&#8220;<br />&#8220;);<br />
    out.println(rb.getString(&#8220;sessions.created&#8221;) + &#8221; &#8220;);<br />
    out.println(new Date(session.getCreationTime()) + &#8220;<br />&#8220;);<br />
    out.println(rb.getString(&#8220;sessions.lastaccessed&#8221;) + &#8221; &#8220;);<br />
    out.println(new Date(session.getLastAccessedTime()));</p>
<p>    String dataName = request.getParameter(&#8220;dataname&#8221;);<br />
    String dataValue = request.getParameter(&#8220;datavalue&#8221;);<br />
    if (dataName != null &#038;&#038; dataValue != null) {<br />
      session.setAttribute(dataName, dataValue);<br />
    }</p>
<p>    out.println(&#8220;
<p>&#8220;);<br />
    out.println(rb.getString(&#8220;sessions.data&#8221;) + &#8220;<br />&#8220;);<br />
    Enumeration names = session.getAttributeNames();<br />
    while (names.hasMoreElements()) {<br />
      String name = (String) names.nextElement();<br />
      String value = session.getAttribute(name).toString();<br />
      out.println(HTMLFilter.filter(name) + &#8221; = &#8221;<br />
          + HTMLFilter.filter(value) + &#8220;<br />&#8220;);<br />
    }</p>
<p>    out.println(&#8220;
<p>&#8220;);</p>
<h2  class="related_post_title">Random Posts</h2><ul class="related_post"><li>October 5, 2008 -- <a href="http://www.bestjavainterviewquestions.com/explain-executequery-method/" title="Explain executeQuery Method">Explain executeQuery Method</a> (0)</li><li>July 21, 2008 -- <a href="http://www.bestjavainterviewquestions.com/java-swings-interview-questions-2/" title="Java Swings Interview Questions">Java Swings Interview Questions</a> (0)</li><li>September 17, 2008 -- <a href="http://www.bestjavainterviewquestions.com/hibernate-introduction/" title="Hibernate Introduction">Hibernate Introduction</a> (0)</li><li>July 7, 2008 -- <a href="http://www.bestjavainterviewquestions.com/java-rmi-interview-questions/" title="Java RMI Interview questions">Java RMI Interview questions</a> (0)</li><li>August 9, 2008 -- <a href="http://www.bestjavainterviewquestions.com/some-important-methos-in-applets/" title="Some important methos in Applets">Some important methos in Applets</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/servlet-session-examples/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Define Stateless Session</title>
		<link>http://www.bestjavainterviewquestions.com/define-stateless-session/</link>
		<comments>http://www.bestjavainterviewquestions.com/define-stateless-session/#comments</comments>
		<pubDate>Sun, 07 Sep 2008 12:36:18 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[Session Tutorials]]></category>
		<category><![CDATA[stateless session]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=283</guid>
		<description><![CDATA[what is stateless Refers to software that does not keep track of configuration settings, transaction information or any other data for the next session. When a program &#8220;does not maintain state&#8221; (is stateless) or when the infrastructure of a system prevents a program from maintaining state, it cannot take information about the last session into [...]]]></description>
			<content:encoded><![CDATA[<p><strong>what is stateless</strong><br />
Refers to software that does not keep track of configuration settings, transaction information or any other data for the next session. When a program &#8220;does not maintain state&#8221; (is stateless) or when the infrastructure of a system prevents a program from maintaining state, it cannot take information about the last session into the next, such as settings the user chose or conditions that arose during processing.</p>
<p><em>The Perfect Example</em><br />
The most ubiquitous stateless environment is the World Wide Web. The HTTP protocol, which is the communications vehicle for Web transactions, is stateless. After a Web page is delivered to the user, the connection is closed. Counter measures, such as the use of cookies, have been developed to maintain the state of a user moving from page to page on a Web site. Contrast with &#8220;stateful,&#8221; which means that continuity is maintained from session to session. See HTTP and cookie.</p>
<h2  class="related_post_title">Related Post</h2><ul class="related_post"><li>March 20, 2009 -- <a href="http://www.bestjavainterviewquestions.com/life-cycle-of-stateless-session-bean/" title="Life Cycle of stateless session bean">Life Cycle of stateless session bean</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/define-stateless-session/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maintaining Servlet Session and EJB Session</title>
		<link>http://www.bestjavainterviewquestions.com/maintaining-servlet-session-and-ejb-session/</link>
		<comments>http://www.bestjavainterviewquestions.com/maintaining-servlet-session-and-ejb-session/#comments</comments>
		<pubDate>Tue, 02 Sep 2008 16:17:44 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[Session Tutorials]]></category>
		<category><![CDATA[ejb session]]></category>
		<category><![CDATA[servlet sessions]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=228</guid>
		<description><![CDATA[Q) How Servlet Maintain Session and EJB Maintain Session? A) Servlets maintain session in ServleContext and EJB’s in EJBContext. Stateful session beans remembers the previous request and responses. But stateless beans do not. stateful does not have pooling concept, whereas the stateless bean instances are pooled. Session Bean Developer programs three classes: &#8211;&#62; Home interface, [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Q) How Servlet Maintain Session and EJB Maintain Session? </strong></p>
<p><strong>A) </strong>Servlets maintain session in ServleContext and EJB’s in EJBContext.  Stateful session beans remembers the previous request and responses. But stateless beans do not. stateful does not have pooling concept, whereas the stateless bean instances are pooled.</p>
<p><em>Session Bean Developer programs three classes: </em></p>
<p><strong>&#8211;&gt; </strong>Home interface, contains methods for creating (and locating for entity beans) bean instances.</p>
<p><strong>&#8211;&gt;</strong>Remote interface, contains business methods the bean offers. –Bean class, contains the business logic of the enterprise bean.</p>
<h2  class="related_post_title">Random Posts</h2><ul class="related_post"><li>September 30, 2008 -- <a href="http://www.bestjavainterviewquestions.com/define-precompile-of-jsp-page/" title="Define Precompile of Jsp page">Define Precompile of Jsp page</a> (0)</li><li>September 17, 2008 -- <a href="http://www.bestjavainterviewquestions.com/example-of-hibernate/" title="Example of Hibernate">Example of Hibernate</a> (0)</li><li>July 12, 2010 -- <a href="http://www.bestjavainterviewquestions.com/gui-examples-using-applets/" title="GUI Examples Using Applets">GUI Examples Using Applets</a> (0)</li><li>December 17, 2008 -- <a href="http://www.bestjavainterviewquestions.com/when-the-port-number-is-changed/" title="When the port number is changed">When the port number is changed</a> (0)</li><li>August 24, 2008 -- <a href="http://www.bestjavainterviewquestions.com/software-architecture-of-ejb/" title="Software  Architecture of EJB">Software  Architecture of EJB</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/maintaining-servlet-session-and-ejb-session/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Difference Between StateFul and Stateless Session Bean</title>
		<link>http://www.bestjavainterviewquestions.com/difference-between-stateful-and-stateless-session-bean/</link>
		<comments>http://www.bestjavainterviewquestions.com/difference-between-stateful-and-stateless-session-bean/#comments</comments>
		<pubDate>Tue, 02 Sep 2008 16:04:44 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[Session Tutorials]]></category>
		<category><![CDATA[stateful and stateless session beans]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=225</guid>
		<description><![CDATA[Q) What is difference between StateFul and Stateless Session Bean? A) A Stateful Session Bean is a bean that is designed to service business processes that span multiple method requests or transactions. Stateful Session beans retain state on behalf of an individual client. Stateless Session Beans do not maintain state. EJB containers pools stateless session [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Q) What is difference between StateFul and Stateless Session Bean?<br />
A) </strong>A Stateful Session Bean is a bean that is designed to service business processes that span multiple method requests or transactions. Stateful Session beans retain state on behalf of an individual client. Stateless Session Beans do not maintain state.</p>
<p>EJB containers pools stateless session beans and reuses them to service many clients. Stateful session beans can be passivated and reused for other clients. But this involves I/O bottlenecks. Because a stateful session bean caches client conversation in memory, a bean failure may result in loosing the entire client conversation. Therefore, while writing a stateful session bean the bean developer has to keep the bean failure and client conversation loss in mind.</p>
<p>In case of stateless session beans, client specific data has to be pushed to the bean for each method invocation which will result in increase in the network traffic. This can be avoided in a number of ways like persisting the client specific data in database or in JNDI. But this also results in I/O performance bottlenecks.</p>
<p>If the business process spans multiple invocations thereby requiring a conversation then stateful session bean will be the ideal choice. On the other hand, if business process lasts only for a single method call, stateless session bean model suits.</p>
<h2  class="related_post_title">Random Posts</h2><ul class="related_post"><li>August 15, 2008 -- <a href="http://www.bestjavainterviewquestions.com/thread-example-for-runnable-interface/" title="Thread example for Runnable Interface">Thread example for Runnable Interface</a> (1)</li><li>April 4, 2009 -- <a href="http://www.bestjavainterviewquestions.com/ejb-interview-questions-2/" title="EJB Interview questions">EJB Interview questions</a> (0)</li><li>July 24, 2008 -- <a href="http://www.bestjavainterviewquestions.com/jsf-important-questions/" title="JSF Important Questions">JSF Important Questions</a> (2)</li><li>October 4, 2008 -- <a href="http://www.bestjavainterviewquestions.com/how-application-creates-a-connection/" title="How application creates a connection">How application creates a connection</a> (0)</li><li>September 16, 2008 -- <a href="http://www.bestjavainterviewquestions.com/converting-hibernate-with-eclipse-integration/" title="Converting Hibernate with Eclipse Integration">Converting Hibernate with Eclipse Integration</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/difference-between-stateful-and-stateless-session-bean/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

