<?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>Kiss Note &#187; J2EE</title>
	<atom:link href="http://kissnote.com/topics/j2ee/feed/" rel="self" type="application/rss+xml" />
	<link>http://kissnote.com</link>
	<description>Keep IT Simple and Stupid</description>
	<lastBuildDate>Mon, 17 May 2010 17:19:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>J2EE &#8211; JNDI</title>
		<link>http://kissnote.com/2009/07/27/j2ee-jndi/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://kissnote.com/2009/07/27/j2ee-jndi/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 23:53:45 +0000</pubDate>
		<dc:creator>shengjie</dc:creator>
				<category><![CDATA[J2EE]]></category>

		<guid isPermaLink="false">http://kissnote.com/?p=180</guid>
		<description><![CDATA[To understand JNDI, the only thing you need to learn is naming. Very simply example, DNS is a naming convention which is used to map the domain to IP. Such as www.test.com &#8211; 9.161.142.75. Another difficult thing to understand is LDAP (Lightweight Directory Access Protocol). most likely you will see it from the product where [...]]]></description>
			<content:encoded><![CDATA[<p>To understand <em><strong>JNDI</strong></em>, the only thing you need to learn is <strong>naming</strong>.</p>
<p>Very simply example,</p>
<p><em><strong>DNS </strong></em>is a naming convention which is used to map the domain to IP. Such as www.test.com &#8211; 9.161.142.75.</p>
<p>Another difficult thing to understand is <em><strong>LDAP </strong></em>(Lightweight Directory Access Protocol). most likely you will see it from the product where you have database storing all the users and you also have a LDAP server mapping all ther users as well (very popular usage).</p>
<p>Thus the LDAP name fn=Shengjie Min, p=SiChuan, c=CN names an LDAP entry fn=Shengjie Min, relative to the entry P=SiChuan,which in turn, is relative to C= CN.</p>
<p>So , back to the JNDI topic. JNDI allows us to look up any java object or LDAP directory based on the context. Hmm&#8230; not following..</p>
<p>Ok, one step by another,</p>
<h3>1. Bindings</h3>
<p>The association of a name with an object is called a <em>binding</em>. For example, a file name is <em>bound</em> to a file.</p>
<p>The DNS contains bindings that map machine names to IP addresses. An LDAP name is bound to an LDAP entry.</p>
<h3>2. Context</h3>
<p>A <em>context</em> is a set of name-to-object bindings</p>
<p>Examples are better than anything <img src='http://kissnote.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  That&#8217;s why i like them.</p>
<p>eg. you have a few database source(JDBC), let&#8217;s say they are a few databases. The context would be those databases entries. And to find one of the specific data source out of them, you will need to do a look up among those entries(context).</p>
<p>Given a code snippet to help out:</p>
<p><em><span style="color: #808080;">Context initCtx = new InitialContext();<span style="color: #ff00ff;"> // actually, to create a brand new initialContext, which can take hashmap as argument, you construct the hashmap to contain name-value pair. Just think of it as defining the scope of the look up</span><br />
</span></em></p>
<p><em><span style="color: #808080;">Context envCtx = (Context) initCtx.lookup(&#8220;java:comp/env&#8221;);</span></em></p>
<p><em><span style="color: #808080;">DataSource ds = (DataSource) envCtx.lookup(&#8220;jdbc/raDataSource&#8221;); </span><br />
</em></p>
]]></content:encoded>
			<wfw:commentRss>http://kissnote.com/2009/07/27/j2ee-jndi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>J2EE &#8211; structure</title>
		<link>http://kissnote.com/2009/07/27/j2ee-structure/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://kissnote.com/2009/07/27/j2ee-structure/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 22:55:04 +0000</pubDate>
		<dc:creator>shengjie</dc:creator>
				<category><![CDATA[J2EE]]></category>

		<guid isPermaLink="false">http://kissnote.com/?p=162</guid>
		<description><![CDATA[J2EE components: Application clients and applests components run on the client. Servlet &#38; JSP are web components run on the server EJB components are business components run on the server Generally, J2EE server is in Pink Client &#60;&#8211;&#62; web tier(JSP/Servlet/Java Bean) &#60;&#8211;&#62;Business tier More precisely, Client &#60;&#8211;&#62; web tier(JSP/Servlet/Java Bean) &#60;&#8211;&#62;Business tier (Entity Bean/Session Bean/Message-Driven [...]]]></description>
			<content:encoded><![CDATA[<h2>J2EE components:</h2>
<p>Application clients and applests components run on the client.</p>
<p>Servlet &amp; JSP are web components run on the server</p>
<p>EJB components are business components run on the server</p>
<p>Generally, J2EE server is in <span style="color: #ff00ff;">Pink </span> <img src='http://kissnote.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span style="color: #000080;">Client &lt;&#8211;&gt; <span style="color: #ff00ff;">web tier(JSP/Servlet/Java Bean) &lt;&#8211;&gt;Business tier</span></span></p>
<p>More precisely,</p>
<p><span style="color: #000080;">Client &lt;&#8211;&gt; <span style="color: #ff00ff;">web tier(JSP/Servlet/Java Bean) &lt;&#8211;&gt;Business tier (Entity Bean/Session Bean/Message-Driven Bean) <span style="color: #000080;">&lt;&#8211;&gt; DB Level</span></span></span></p>
<h2><span style="color: #000080;"><span style="color: #ff00ff;"><span style="color: #000080;"><span style="color: #000000;">J2EE Containers:</span><br />
</span></span></span></h2>
<p>Containers, no need to spend too much time here. Easy and Stupid.</p>
<ul>
<li>Application client container</li>
<li>web container</li>
<li>EJB container</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://kissnote.com/2009/07/27/j2ee-structure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>J2EE &#8211; Http Session</title>
		<link>http://kissnote.com/2009/07/27/j2ee-http-session/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://kissnote.com/2009/07/27/j2ee-http-session/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 20:31:28 +0000</pubDate>
		<dc:creator>shengjie</dc:creator>
				<category><![CDATA[J2EE]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[servlet]]></category>
		<category><![CDATA[session]]></category>

		<guid isPermaLink="false">http://kissnote.com/?p=157</guid>
		<description><![CDATA[Very Simple Example。Http Session is stateless, keep track what user is doing. SessionServlet public class SersionServlet extends HttpServlet implements Servlet { HttpSerssions session = request.getSession(false); //takes any two params, false, if user has session, give it to me; true, if user has no session, create one if(session == null) { session = reuqest.getSession(true); session.setAttribute(&#8220;count&#8221;, hitCount); [...]]]></description>
			<content:encoded><![CDATA[<p>Very Simple Example。Http Session is stateless, keep track what user is doing.</p>
<p>SessionServlet</p>
<p><span style="color: #808080;"><em>public class SersionServlet extends HttpServlet implements Servlet {</em></span></p>
<p><span style="color: #c0c0c0;"><em><span style="color: #808080;"> HttpSerssions session = request.getSession(false); </span> <span style="color: #0000ff;">//takes any two params, false, if user has session, give it to me; true, if user has no session, create one</span></em></span></p>
<p><span style="color: #c0c0c0;"><em> <span style="color: #808080;">if(session == null) {</span></em></span></p>
<p><span style="color: #808080;"><em> session = reuqest.getSession(true);</em></span></p>
<p><span style="color: #808080;"><em> session.setAttribute(&#8220;count&#8221;, hitCount);</em></span></p>
<p><span style="color: #808080;"><em> }</em></span></p>
<p><span style="color: #808080;"><em> Integer hitCount = (Integer)session.getAttribte(&#8220;count&#8221;);</em></span></p>
<p><span style="color: #808080;"><em> hitCount = new Integer(hitCount.intValue()) + 1;</em></span></p>
<p><span style="color: #808080;"><em> response.getWriter().print(&#8220;Number of times at this page &#8221; + hitCount.intValue() );</em></span></p>
<p><span style="color: #808080;"><em>}</em></span></p>
<p>So, when user hit this servlet, it will be increased by 1 everytime user refreshes the page.</p>
]]></content:encoded>
			<wfw:commentRss>http://kissnote.com/2009/07/27/j2ee-http-session/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
