<?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>Great Tasting Java &#187; Code Examples</title>
	<atom:link href="http://www.greattastingjava.com/wordpress/index.php/category/code-examples/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.greattastingjava.com/wordpress</link>
	<description>Headley Williamson's Java code, answers, tutorials, and courses</description>
	<lastBuildDate>Wed, 21 Jul 2010 17:15:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>ATG Dynamo DRP Hung threads solution</title>
		<link>http://www.greattastingjava.com/wordpress/index.php/2007/06/19/atg-dynamo-drp-hung-threads-solution/</link>
		<comments>http://www.greattastingjava.com/wordpress/index.php/2007/06/19/atg-dynamo-drp-hung-threads-solution/#comments</comments>
		<pubDate>Tue, 19 Jun 2007 14:44:17 +0000</pubDate>
		<dc:creator>hwilliamson</dc:creator>
				<category><![CDATA[Code Examples]]></category>
		<category><![CDATA[J2EE]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Servlets]]></category>

		<guid isPermaLink="false">http://www.greattastingjava.com/wordpress/2007/06/19/atg-dynamo-drp-hung-threads-solution/</guid>
		<description><![CDATA[What is a DRP Thread?
DRP stands for Distribution and Replication Protocol.  It is the protocol for communication between an HTTP server (Web server) and an application Server (ATG). When a user clicks on a link or summits a form in his/her web browser, that information or the “request” is sent to a webserver. The [...]]]></description>
			<content:encoded><![CDATA[<p>What is a DRP Thread?<br />
DRP stands for Distribution and Replication Protocol.  It is the protocol for communication between an HTTP server (Web server) and an application Server (ATG). When a user clicks on a link or summits a form in his/her web browser, that information or the “request” is sent to a webserver. The webserver examines the request and determines if it needs to pass on the request to the application server. If it does need to pass the request, it uses the DRP protocol to send the message. Inside the application server when it receives a request, it starts a DRP thread to handle the request. That thread performs the necessary actions, and returns the response to the webserver, which then returns the response to the user’s browser.</p>
<p>Why do they get Hung?<br />
The main reason the threads hang is because it can not finish the request in a timely manner. If your data needs continuously updating, some of queries loose efficiency because their execution paths over time need to be re-analyzed. Over the last couple years we have seen this in several of our queries. </p>
<p>Since we have a set number of available DRP threads (40 in our case), when they are all hanging, the application server is no longer able to serve requests. </p>
<p>This problem is an Enterprise problem. This means all ATG applications run into this problem, if the queries don’t return.</p>
<p>The solution to the problem.</p>
<p>Overview<br />
The solution is to first monitor and identify DRP hung threads, send email regarding their hung status, and then kill them before they can do damage. This solution requires a monitor running inside the application server that will periodically take an inventory of the running DRP threads. When a thread age reaches a predetermined threshold, it will be terminated, and information about the terminated thread will be sent to a predetermined email for evaluation.</p>
<p>The following are the control inputs for the DRPThread Monitor stored in a property file. The property file is loaded upon startup.</p>
<p>This tells the monitor to auto-start.<br />
threadMonitorAutoStart = true</p>
<p>This is how often it checks the DRP threads<br />
threadMonitorWaitInterval = 5000</p>
<p>This is percent of DRP threads in use before checking threshold<br />
threadMonitorThreshold= 80</p>
<p>This is the Age limit of threads. When the age limit is surpassed<br />
thresholdAgeLimit = 300000</p>
<p>This is the max age of any thread. A thread over this age is killed<br />
maxThreadAge= 1800000</p>
<p>List of email address sent notifications when a DRP thread is killed<br />
emailNotificationList = hwilliamson@greattastingjava.com</p>
<p>Pseudo Code </p>
<p>1.	Application server starts up<br />
2.	Starts DRP Monitor</p>
<p>a.	If threadMonitorAutoStart = true, then monitor continues to start up, else it stops.<br />
b.	Loop until forced stop</p>
<ul>
i.	Check DRP server<br />
1.	percent active thread > threadMonitorThreshold &#038;&#038; age of thread > thresholdAgeLimit) || age of thread > maxThreadAge  then<br />
a.	Email info about hung thread<br />
b.	Kill thread<br />
ii.	Sleep threadMonitorWaitInterval
</ul>
<p>Code Sample</p>
<p>		while (!forcedStop) {</p>
<p>			try {</p>
<p>				RequestServerHandler handlers[] = drpServer.getRequestHandlers();</p>
<p>				int activeCount = drpServer.getActiveHandlerCount();</p>
<p>				double percentActive = (activeCount/handlers.length) *100.0;</p>
<p>				for (int i = 0; i < handlers.length; i++) {</p>
<p>					if (handlers[i] instanceof DrpServerConnection) {</p>
<p>						DrpServerConnection connection = (DrpServerConnection) handlers[i];<br />
						if (connection.getHandlingRequest()) {</p>
<p>							if ((percentActive> threadMonitorThreshold &#038;&#038; connection.getCurrentRequestTime() > thresholdAgeLimit) ||connection.getCurrentRequestTime() > maxThreadAge)<br />
							{<br />
								logger.debug(&#8221;killing:&#8221; + connection);</p>
<p>								String path = connection.getCurrentRequestPathInfo();<br />
								long time = connection.getCurrentRequestTime();</p>
<p>								connection.killHandler();</p>
<p>								Mail mail = new Mail();<br />
								mail.postMail(emailNotificationList,&#8221;DRP Thread Killed&#8221;, &#8220;Path:&#8221; +path +&#8221;\n&#8221;<br />
																							+&#8221;Time:&#8221; +time+&#8221;\n&#8221;,&#8221;hwilliamson@greattastingjava.com&#8221;);<br />
								logger.debug(&#8221;emailing:&#8221; + emailNotificationList);</p>
<p>							}<br />
						}<br />
					}<br />
				}<br />
				sleepDRPThreadMonitor();<br />
			} catch (Exception ex)<br />
			{<br />
				ex.printStackTrace();<br />
			}<br />
		}</p>
]]></content:encoded>
			<wfw:commentRss>http://www.greattastingjava.com/wordpress/index.php/2007/06/19/atg-dynamo-drp-hung-threads-solution/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to build a high quality Client/Server Java application &#8211; a Java Chat Client/Server example Part5</title>
		<link>http://www.greattastingjava.com/wordpress/index.php/2006/04/05/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part5/</link>
		<comments>http://www.greattastingjava.com/wordpress/index.php/2006/04/05/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part5/#comments</comments>
		<pubDate>Wed, 05 Apr 2006 18:38:34 +0000</pubDate>
		<dc:creator>hwilliamson</dc:creator>
				<category><![CDATA[Client/Server]]></category>
		<category><![CDATA[Code Examples]]></category>
		<category><![CDATA[Course]]></category>
		<category><![CDATA[Swing]]></category>
		<category><![CDATA[multithreading]]></category>

		<guid isPermaLink="false">http://www.greattastingjava.com/wordpress/2006/04/05/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part5/</guid>
		<description><![CDATA[ Part1 , Part2 , Part3 , Part4 ,Part5
Now that we have tested out Sockets and threads, we need to combine the two to make a concurrent server . A concurrent sever  can handle more than one client at a time. It works like the old time phone operators. It gets a connecting client [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.greattastingjava.com/wordpress/2006/03/08/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part1/" > Part1 </a>,<a href="http://www.greattastingjava.com/wordpress/2006/03/08/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part2/" > Part2 </a>,<a href="http://www.greattastingjava.com/wordpress/2006/03/15/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part3/" > Part3 </a>,<a href="http://www.greattastingjava.com/wordpress/2006/03/20/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part4/" > Part4 </a>,<a href="http://www.greattastingjava.com/wordpress/2006/04/05/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part5/">Part5</a></p>
<p>Now that we have tested out Sockets and threads, we need to combine the two to make a concurrent server . A concurrent sever  can handle more than one client at a time. It works like the old time phone operators. It gets a connecting client  call, then it creates a thread to handle that call, and then goes back to listen for the next caller.</p>
<p>Concurrent Sever example</p>
<p><a href="http://www.greattastingjava.com/downloads/Client3.java">Client 3</a></p>
<p><a href="http://www.greattastingjava.com/downloads/Server3.java">Server 3</a></p>
<p>Run server and then start two instances of the client3. You should see in the server console that it is handling both users concurrently, hence a concurrent server.</p>
<p><tags><br />
Java,/client/server,course,chat,sockets,network,swing<br />
</tags></p>
]]></content:encoded>
			<wfw:commentRss>http://www.greattastingjava.com/wordpress/index.php/2006/04/05/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part5/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to build a high quality Client/Server Java application &#8211; a Java Chat Client/Server example Part4</title>
		<link>http://www.greattastingjava.com/wordpress/index.php/2006/03/20/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part4/</link>
		<comments>http://www.greattastingjava.com/wordpress/index.php/2006/03/20/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part4/#comments</comments>
		<pubDate>Mon, 20 Mar 2006 21:00:22 +0000</pubDate>
		<dc:creator>hwilliamson</dc:creator>
				<category><![CDATA[Client/Server]]></category>
		<category><![CDATA[Code Examples]]></category>
		<category><![CDATA[Course]]></category>
		<category><![CDATA[multithreading]]></category>

		<guid isPermaLink="false">http://www.greattastingjava.com/wordpress/2006/03/20/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part4/</guid>
		<description><![CDATA[ Part1 , Part2 , Part3 , Part4 ,Part5
In the next example we will start 3 threads. Each thread will print a unique string and then go to sleep for set time and then print another string and so on.  There are two ways to create a thread: One is to subclass the Thread [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.greattastingjava.com/wordpress/2006/03/08/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part1/" > Part1 </a>,<a href="http://www.greattastingjava.com/wordpress/2006/03/08/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part2/" > Part2 </a>,<a href="http://www.greattastingjava.com/wordpress/2006/03/15/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part3/" > Part3 </a>,<a href="http://www.greattastingjava.com/wordpress/2006/03/20/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part4/" > Part4 </a>,<a href="http://www.greattastingjava.com/wordpress/2006/04/05/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part5/">Part5</a></p>
<p>In the next example we will start 3 threads. Each thread will print a unique string and then go to sleep for set time and then print another string and so on.  There are two ways to create a thread: One is to subclass the Thread class the other is to implement “runnable’.  I will show you how to do it both ways.  Most of the time you want to subclass a thread, but it some situations it is far easier to implement Runnable. For example when you have to pass a great amount of data to the thread class it may be easier to just create the thread in the class you are in.</p>
<p><a href="http://www.greattastingjava.com/downloads/Thread1.java">Extending Thread example</a></p>
<p><a href="http://www.greattastingjava.com/downloads/Thread2.java">Implementing Runnable example</a></p>
<p><tags><br />
Java,/client/server,course,chat,sockets,network<br />
</tags></p>
]]></content:encoded>
			<wfw:commentRss>http://www.greattastingjava.com/wordpress/index.php/2006/03/20/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part4/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Example Code: A simple Socket example</title>
		<link>http://www.greattastingjava.com/wordpress/index.php/2006/03/20/example-code-a-simple-socket-example/</link>
		<comments>http://www.greattastingjava.com/wordpress/index.php/2006/03/20/example-code-a-simple-socket-example/#comments</comments>
		<pubDate>Mon, 20 Mar 2006 20:39:18 +0000</pubDate>
		<dc:creator>hwilliamson</dc:creator>
				<category><![CDATA[Client/Server]]></category>
		<category><![CDATA[Code Examples]]></category>

		<guid isPermaLink="false">http://www.greattastingjava.com/wordpress/2006/03/20/example-code-a-simple-socket-example/</guid>
		<description><![CDATA[This simple code is an application that a client sends one message across the net and the server gets that message and prints it out.  
In order for you to send a message across the internet you need two things the IP address of the machine and the port number the server is listening [...]]]></description>
			<content:encoded><![CDATA[<p>This simple code is an application that a client sends one message across the net and the server gets that message and prints it out.  </p>
<p>In order for you to send a message across the internet you need two things the IP address of the machine and the port number the server is listening at. You see all internet based software listens to a port. For example Web servers listen to port 80.  </p>
<p>The IP address we are going to use is “localhost” which means your current local machine/desktop. The IP address we are choosing is 51234. We could have picked any number above 1024. </p>
<p>Here is the example:</p>
<p><a href="/downloads/Client1.java">Client1</a></p>
<p><a href="/downloads/Server1.java">Server1</a></p>
<p>Run the server first, then the client.</p>
<p><tags><br />
Java,/client/server,course,sockets,network<br />
</tags></p>
]]></content:encoded>
			<wfw:commentRss>http://www.greattastingjava.com/wordpress/index.php/2006/03/20/example-code-a-simple-socket-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to build a high quality Client/Server Java application &#8211; a Java Chat Client/Server example Part3</title>
		<link>http://www.greattastingjava.com/wordpress/index.php/2006/03/15/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part3/</link>
		<comments>http://www.greattastingjava.com/wordpress/index.php/2006/03/15/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part3/#comments</comments>
		<pubDate>Wed, 15 Mar 2006 16:42:45 +0000</pubDate>
		<dc:creator>hwilliamson</dc:creator>
				<category><![CDATA[Client/Server]]></category>
		<category><![CDATA[Code Examples]]></category>
		<category><![CDATA[Course]]></category>
		<category><![CDATA[Swing]]></category>
		<category><![CDATA[multithreading]]></category>

		<guid isPermaLink="false">http://www.greattastingjava.com/wordpress/2006/03/15/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part3/</guid>
		<description><![CDATA[ Part1 , Part2 , Part3 , Part4 ,Part5
The next example is to add a level of complexity to our first example.
The client will connect to the server, send 20 messages, and then terminate.  The server will listen for a client, read messages, and print out the messages from that client until the client [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.greattastingjava.com/wordpress/2006/03/08/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part1/" > Part1 </a>,<a href="http://www.greattastingjava.com/wordpress/2006/03/08/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part2/" > Part2 </a>,<a href="http://www.greattastingjava.com/wordpress/2006/03/15/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part3/" > Part3 </a>,<a href="http://www.greattastingjava.com/wordpress/2006/03/20/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part4/" > Part4 </a>,<a href="http://www.greattastingjava.com/wordpress/2006/04/05/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part5/">Part5</a></p>
<p>The next example is to add a level of complexity to our first example.</p>
<p>The client will connect to the server, send 20 messages, and then terminate.  The server will listen for a client, read messages, and print out the messages from that client until the client disconnects. Then the server will go back and wait for the next client. </p>
<p>After testing our new servers and clients I am now comfortable with Java.net technology. And I am ready to incorporate more. </p>
<p><a href="http://www.greattastingjava.com/downloads/Client2.java">Client</a></p>
<p><a href="http://www.greattastingjava.com/downloads/Server2.java">Server</a></p>
<p><tags><br />
Java,/client/server,course,chat,sockets,network<br />
</tags></p>
]]></content:encoded>
			<wfw:commentRss>http://www.greattastingjava.com/wordpress/index.php/2006/03/15/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part3/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How to build a high quality Client/Server Java application &#8211; a Java Chat Client/Server example Part2</title>
		<link>http://www.greattastingjava.com/wordpress/index.php/2006/03/08/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part2/</link>
		<comments>http://www.greattastingjava.com/wordpress/index.php/2006/03/08/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part2/#comments</comments>
		<pubDate>Wed, 08 Mar 2006 20:04:14 +0000</pubDate>
		<dc:creator>hwilliamson</dc:creator>
				<category><![CDATA[Client/Server]]></category>
		<category><![CDATA[Code Examples]]></category>
		<category><![CDATA[Course]]></category>
		<category><![CDATA[Swing]]></category>
		<category><![CDATA[multithreading]]></category>

		<guid isPermaLink="false">http://www.greattastingjava.com/wordpress/2006/03/08/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part2/</guid>
		<description><![CDATA[ Part1 , Part2 , Part3 , Part4 ,Part5
Well since it is a network application, we should start by writing some simple network code to make sure that we fully understand the technology. 
The first simple code we are going to write is an application that a client sends one message across the net and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.greattastingjava.com/wordpress/2006/03/08/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part1/" > Part1 </a>,<a href="http://www.greattastingjava.com/wordpress/2006/03/08/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part2/" > Part2 </a>,<a href="http://www.greattastingjava.com/wordpress/2006/03/15/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part3/" > Part3 </a>,<a href="http://www.greattastingjava.com/wordpress/2006/03/20/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part4/" > Part4 </a>,<a href="http://www.greattastingjava.com/wordpress/2006/04/05/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part5/">Part5</a></p>
<p>Well since it is a network application, we should start by writing some simple network code to make sure that we fully understand the technology. </p>
<p>The first simple code we are going to write is an application that a client sends one message across the net and the server gets that message and prints it out.  </p>
<p>In order for you to send a message across the internet you need two things the IP address of the machine and the port number the server is listening at. You see all internet based software listens to a port. For example Web servers listen to port 80.  </p>
<p>The IP address we are going to use is “localhost” which means your current local machine/desktop. The IP address we are choosing is 51234. We could have picked any number above 1024. </p>
<p>Here is the example:</p>
<p><a href="/downloads/Client1.java">Client1</a></p>
<p><a href="/downloads/Server1.java">Server1</a></p>
<p>Run the server first, then the client.</p>
<p><tags><br />
Java,/client/server,course,chat,sockets,network<br />
</tags></p>
]]></content:encoded>
			<wfw:commentRss>http://www.greattastingjava.com/wordpress/index.php/2006/03/08/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part2/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How to build a high quality Client/Server Java application &#8211; a Java Chat Client/Server example Part1</title>
		<link>http://www.greattastingjava.com/wordpress/index.php/2006/03/08/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part1/</link>
		<comments>http://www.greattastingjava.com/wordpress/index.php/2006/03/08/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part1/#comments</comments>
		<pubDate>Wed, 08 Mar 2006 16:59:18 +0000</pubDate>
		<dc:creator>hwilliamson</dc:creator>
				<category><![CDATA[Client/Server]]></category>
		<category><![CDATA[Code Examples]]></category>
		<category><![CDATA[Course]]></category>
		<category><![CDATA[Swing]]></category>
		<category><![CDATA[multithreading]]></category>

		<guid isPermaLink="false">http://www.greattastingjava.com/wordpress/2006/03/08/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part1/</guid>
		<description><![CDATA[ Part1 , Part2 , Part3 , Part4 ,Part5
The best way to show you how to build a high quality Java application is to take you through building one.
We are going to build a Chat application from scratch. While we are building this Chat, I will introduce many concepts to help you build a high [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.greattastingjava.com/wordpress/2006/03/08/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part1/" > Part1 </a>,<a href="http://www.greattastingjava.com/wordpress/2006/03/08/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part2/" > Part2 </a>,<a href="http://www.greattastingjava.com/wordpress/2006/03/15/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part3/" > Part3 </a>,<a href="http://www.greattastingjava.com/wordpress/2006/03/20/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part4/" > Part4 </a>,<a href="http://www.greattastingjava.com/wordpress/2006/04/05/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part5/">Part5</a></p>
<p>The best way to show you how to build a high quality Java application is to take you through building one.</p>
<p>We are going to build a Chat application from scratch. While we are building this Chat, I will introduce many concepts to help you build a high quality application.</p>
<p>Ok let’s get started.  </p>
<p>First thing is to define a scope. In other words what we are going to build.</p>
<p>SCOPE: The Chat application we are going to build will be a client/sever application. The client can run on its own or as an Applet. The chat application will have multiple chat rooms and features like whisper (allows a user to whisper to another user).  It would also be nice to add a white board so people can draw pictures together. Streaming video/audio would also be nice.  Why not throw in SSL security too.  </p>
<p>Boy if I can build the above I would be impressed. </p>
<p><tags><br />
Java,/client/server,course,chat,sockets,network<br />
</tags></p>
]]></content:encoded>
			<wfw:commentRss>http://www.greattastingjava.com/wordpress/index.php/2006/03/08/how-to-build-a-high-quality-clientserver-java-application-a-java-chat-clientserver-example-part1/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Example code: Java Spring Framework HelloWorld example</title>
		<link>http://www.greattastingjava.com/wordpress/index.php/2006/01/30/example-code-java-spring-framework-helloworld-example/</link>
		<comments>http://www.greattastingjava.com/wordpress/index.php/2006/01/30/example-code-java-spring-framework-helloworld-example/#comments</comments>
		<pubDate>Mon, 30 Jan 2006 20:56:24 +0000</pubDate>
		<dc:creator>hwilliamson</dc:creator>
				<category><![CDATA[Code Examples]]></category>
		<category><![CDATA[J2EE]]></category>

		<guid isPermaLink="false">http://www.greattastingjava.com/wordpress/2006/01/30/example-code-java-spring-framework-helloworld-example/</guid>
		<description><![CDATA[I have been trying to learn about the Java Spring framework,
and here is a great Helloworld example I found: HERE
Technorati Tags:  Spring,  Java,  framework,  helloword,  code example 
]]></description>
			<content:encoded><![CDATA[<p>I have been trying to learn about the Java Spring framework,<br />
and here is a great Helloworld example I found: <a href="http://www.drrockit.com/space/Java/Simple+Spring+Demo ">HERE</a></p>
<p>Technorati Tags: <a href="http://technorati.com/tag/Spring" rel="tag"> Spring</a>, <a href="http://technorati.com/tag/Java" rel="tag"> Java</a>, <a href="http://technorati.com/tag/framework" rel="tag"> framework</a>, <a href="http://technorati.com/tag/helloword" rel="tag"> helloword</a>, <a href="http://technorati.com/tag/code+example" rel="tag"> code example </a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.greattastingjava.com/wordpress/index.php/2006/01/30/example-code-java-spring-framework-helloworld-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Code Example: Data Transfer Object DTO or Data Beans</title>
		<link>http://www.greattastingjava.com/wordpress/index.php/2006/01/17/code-example-data-transfer-object-dto-or-data-beans/</link>
		<comments>http://www.greattastingjava.com/wordpress/index.php/2006/01/17/code-example-data-transfer-object-dto-or-data-beans/#comments</comments>
		<pubDate>Tue, 17 Jan 2006 23:28:50 +0000</pubDate>
		<dc:creator>hwilliamson</dc:creator>
				<category><![CDATA[Code Examples]]></category>
		<category><![CDATA[Course]]></category>
		<category><![CDATA[JDBC]]></category>

		<guid isPermaLink="false">http://www.greattastingjava.com/wordpress/2006/01/17/code-example-data-transfer-object-dto-or-data-beans/</guid>
		<description><![CDATA[When you are implementing you jdbc layer, you need a solid way to create Data Transfer Objects (DTO&#8217;s) or  Data Beans . This is the way I implement this.

Data Transfer Object interface.




package dto;

import jdbc.DAObject;

public interface IDTO {

	public void execute() throws Exception;
	public DAObject [] getData();
	public DAObject getFirstRowData();

}




Data Transfer Object. Base class.





package dto;

import java.util.ArrayList;

import jdbc.DAObject;
import jdbc.JDBCSessionAccessor;
import [...]]]></description>
			<content:encoded><![CDATA[<p>When you are implementing you jdbc layer, you need a solid way to create Data Transfer Objects (DTO&#8217;s) or  Data Beans . This is the way I implement this.<br />
<span id="more-17"></span><br />
Data Transfer Object interface.</p>
<table width="100" border="1" class="ex" cellspacing="0" cellpadding="2">
<tr>
<td>
<pre>
package dto;

import jdbc.DAObject;

public interface IDTO {

	public void execute() throws Exception;
	public DAObject [] getData();
	public DAObject getFirstRowData();

}
</pre>
</td>
</tr>
</table>
<p>Data Transfer Object. Base class.</p>
<table width="100" border="1" class="ex" cellspacing="0" cellpadding="2">
<tr>
<td>
<pre>

package dto;

import java.util.ArrayList;

import jdbc.DAObject;
import jdbc.JDBCSessionAccessor;
import jdbc.JDBCSessionAccessorHome;
import jndi.JNDILocator;
import jndi.JNDILookupNames;

abstract public class DTO implements IDTO{

	DAObject [] data;

	public void runQuery(String query, ArrayList list ) throws Exception
	{
		JNDILocator jndi = JNDILocator.getJNDILocator();
		JDBCSessionAccessorHome home  = (JDBCSessionAccessorHome) jndi.getJNDIObject(JNDILookupNames.JDBCSESSIONBEAN);
		JDBCSessionAccessor	jdbc = home.create();
		DAObject [] rset = (DAObject []) jdbc.query(query,list.toArray());

		if (rset !=null)
		{
			data = rset;
		}
	}

	public DAObject getFirstRowData()
	{
		if (data !=null &#038;&#038; data[0] != null)
		{
			return data[0];
		}
		return null;
	}

	/**
	 * @return Returns the data.
	 */
	public DAObject [] getData() {
		return data;
	}
	/**
	 * @param data The data to set.
	 */
	public void setData(DAObject [] p_data) {
		this.data = p_data;
	}

}
</pre>
</td>
</tr>
</table>
<p>Data Transfer Object. Example quey implementation</p>
<table width="100" border="1" class="ex" cellspacing="0" cellpadding="2">
<tr>
<td>
<pre>

package dto;

import java.util.ArrayList;

class DTOTable1  extends DTO {

	public static String COLUMN1 = "column1";
	public static String FIELD_QUERY = "SELECT  column1  FROM table1 where field1 = ?"; 

	private String field;

	public DTOTable1 ()
	{

	}

	public String getField() {
		return eventMessageId;
	}

	public void setField(String rowId) {
		field= rowId;
	}
	public LabelType(String p_field)
	{
		field=p_field;
	}
	public void execute() throws Exception
	{
		ArrayList list = new ArrayList();
		list.add(getField());
		runQuery(FIELD_QUERY,list);

	}
</pre>
</td>
</tr>
</table>
<p>A use to use it&#8230;..</p>
<table width="100" border="1" class="ex" cellspacing="0" cellpadding="2">
<tr>
<td>
<pre>
DTOTable1 label =  new DTOTable1();
label.setField("somevalue");
label.execute();
String lableType =(String) label.getFirstRowData().getProperty(DTOTable1.COLUMN1);
</pre>
</td>
</tr>
</table>
<p><tags><br />
java,code samples, example,jdbc, example,dto<br />
</tags></p>
]]></content:encoded>
			<wfw:commentRss>http://www.greattastingjava.com/wordpress/index.php/2006/01/17/code-example-data-transfer-object-dto-or-data-beans/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Free Java Client/Server Chat applet Software binaries and source</title>
		<link>http://www.greattastingjava.com/wordpress/index.php/2006/01/11/free-java-clientserver-chat-applet-binaries-and-source/</link>
		<comments>http://www.greattastingjava.com/wordpress/index.php/2006/01/11/free-java-clientserver-chat-applet-binaries-and-source/#comments</comments>
		<pubDate>Thu, 12 Jan 2006 01:00:49 +0000</pubDate>
		<dc:creator>hwilliamson</dc:creator>
				<category><![CDATA[AWT]]></category>
		<category><![CDATA[Client/Server]]></category>
		<category><![CDATA[Code Examples]]></category>
		<category><![CDATA[multithreading]]></category>

		<guid isPermaLink="false">http://www.greattastingjava.com/wordpress/2006/01/11/free-java-clientserver-chat-applet-binaries-and-source/</guid>
		<description><![CDATA[I wrote PriadoChat client/server a long time ago to sell. Now I have decided to give it away for Free.
PriadoChat offers Multiple chatrooms, PriadoChat is an easily customizable chat engine for your website. It is powered by Java, but can be embedded into static HTML pages, PHP scripts, ASP scripts, JSP scripts, etc. The colors [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote PriadoChat client/server a long time ago to sell. Now I have decided to give it away for Free.</p>
<p>PriadoChat offers Multiple chatrooms, PriadoChat is an easily customizable chat engine for your website. It is powered by Java, but can be embedded into static HTML pages, PHP scripts, ASP scripts, JSP scripts, etc. The colors and server port are completely configurable.</p>
<p><a href="http://www.greattastingjava.com/downloads/priadochat.zip">Binaries</a></p>
<p><a href="http://www.greattastingjava.com/downloads/priadochatsrc.zip">Source</a></p>
<p> This product is under the GPL License  <a href="http://www.gnu.org/licenses/gpl.txt">GPL License</a></p>
<p><tags><br />
Java,client/server, networking,chat, awt<br />
</tags></p>
]]></content:encoded>
			<wfw:commentRss>http://www.greattastingjava.com/wordpress/index.php/2006/01/11/free-java-clientserver-chat-applet-binaries-and-source/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
