<?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>{Complexity} &#187; Java</title>
	<atom:link href="http://technote.wsjoung.com/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://technote.wsjoung.com</link>
	<description>simple note</description>
	<lastBuildDate>Wed, 09 Nov 2011 02:12:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Spring MVC + Tiles</title>
		<link>http://technote.wsjoung.com/2009/12/13/spring-mvc-tiles/</link>
		<comments>http://technote.wsjoung.com/2009/12/13/spring-mvc-tiles/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 02:14:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[Tiles]]></category>

		<guid isPermaLink="false">http://technote.wsjoung.com/?p=126</guid>
		<description><![CDATA[1. create web.xml &#60;?xml version="1.0" encoding="UTF-8"?&#62; &#60;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"&#62; &#60;servlet&#62; &#60;servlet-name&#62;action&#60;/servlet-name&#62; &#60;servlet-class&#62;org.springframework.web.servlet.DispatcherServlet&#60;/servlet-class&#62; &#60;load-on-startup&#62;1&#60;/load-on-startup&#62; &#60;/servlet&#62; &#60;servlet-mapping&#62; &#60;servlet-name&#62;action&#60;/servlet-name&#62; &#60;url-pattern&#62;*.do&#60;/url-pattern&#62; &#60;/servlet-mapping&#62; &#60;/web-app&#62; 2. create action-servlet.xml &#60;?xml version="1.0" encoding="UTF-8"?&#62; &#60;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"&#62; &#60;bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"&#62; &#60;property name="basename" value="message" /&#62; &#60;/bean&#62; &#60;bean id="testController" class="com.bluewiseinc.erp.common.web.TestController"&#62; &#60;property name="methodNameResolver" ref="methodNameResolver" /&#62; &#60;/bean&#62; &#60;bean id="methodNameResolver" class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver"&#62; &#60;property [...]]]></description>
			<content:encoded><![CDATA[<p><strong>1. create web.xml</strong><br />
<code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br />
&lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"&gt;<br />
  &lt;servlet&gt;<br />
  	&lt;servlet-name&gt;action&lt;/servlet-name&gt;<br />
	  &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;<br />
	  &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;<br />
  &lt;/servlet&gt;<br />
  &lt;servlet-mapping&gt;<br />
    &lt;servlet-name&gt;action&lt;/servlet-name&gt;<br />
    &lt;url-pattern&gt;*.do&lt;/url-pattern&gt;<br />
  &lt;/servlet-mapping&gt;<br />
&lt;/web-app&gt;</code></p>
<p><strong>2. create action-servlet.xml</strong><br />
<code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br />
&lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"&gt;</p>
<p>  &lt;bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"&gt;<br />
    &lt;property name="basename" value="message" /&gt;<br />
  &lt;/bean&gt;  </p>
<p>  &lt;bean id="testController" class="com.bluewiseinc.erp.common.web.TestController"&gt;<br />
	&lt;property name="methodNameResolver" ref="methodNameResolver" /&gt;<br />
  &lt;/bean&gt;  </p>
<p>  &lt;bean id="methodNameResolver" class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver"&gt;<br />
    &lt;property name="paramName"&gt;<br />
      &lt;value&gt;med&lt;/value&gt;<br />
    &lt;/property&gt;<br />
    &lt;property name="defaultMethodName"&gt;<br />
      &lt;value&gt;userMain&lt;/value&gt;<br />
    &lt;/property&gt;<br />
  &lt;/bean&gt;</p>
<p>  &lt;!--<br />
  &lt;bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;<br />
	&lt;property name="viewClass"&gt;<br />
	  &lt;value&gt;org.springframework.web.servlet.view.JstlView&lt;/value&gt;<br />
	&lt;/property&gt;<br />
	&lt;property name="cache" value="false" /&gt;<br />
	&lt;property name="prefix" value="/WEB-INF/view/" /&gt;<br />
	&lt;property name="suffix" value=".jsp" /&gt;<br />
  &lt;/bean&gt;<br />
  --&gt;<br />
  &lt;bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"&gt;<br />
    &lt;property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/&gt;<br />
  &lt;/bean&gt;</p>
<p>  &lt;bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"&gt;<br />
	&lt;property name="mappings"&gt;<br />
	  &lt;bean class="org.springframework.beans.factory.config.PropertiesFactoryBean"&gt;<br />
	    &lt;property name="location"&gt;<br />
	      &lt;value&gt;/WEB-INF/UrlMap.properties&lt;/value&gt;<br />
	    &lt;/property&gt;<br />
	  &lt;/bean&gt;<br />
    &lt;/property&gt;<br />
  &lt;/bean&gt;</p>
<p>  &lt;bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer"&gt;<br />
    &lt;property name="definitions"&gt;<br />
      &lt;list&gt;<br />
        &lt;value&gt;/WEB-INF/tiles-def.xml&lt;/value&gt;<br />
      &lt;/list&gt;<br />
    &lt;/property&gt;<br />
  &lt;/bean&gt;</p>
<p>  &lt;bean id="tilesViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"&gt;<br />
    &lt;property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/&gt;<br />
  &lt;/bean&gt;<br />
&lt;/beans&gt;</code></p>
<p><strong>3. create TestController</strong><br />
<code>package com.bluewiseinc.erp.common.web;<br />
import javax.servlet.http.HttpServletRequest;<br />
import javax.servlet.http.HttpServletResponse;<br />
import org.springframework.web.servlet.ModelAndView;<br />
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;</p>
<p>public class TestController extends MultiActionController {<br />
	public ModelAndView testMain(HttpServletRequest request, HttpServletResponse response) throws Exception {<br />
		return new ModelAndView("test/test_main", "testMain", null);<br />
	}<br />
}</code></p>
<p><strong>4. UrlMap.properties</strong><br />
<code>## test module mapping<br />
/test/index.do=testController</code></p>
<p><strong>5. tiles-def.xml</strong><br />
<code>&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt;<br />
&lt;!DOCTYPE tiles-definitions PUBLIC<br />
       "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"<br />
       "http://tiles.apache.org/dtds/tiles-config_2_0.dtd"&gt;</p>
<p>&lt;tiles-definitions&gt;<br />
  &lt;definition name="defaultTemplate" template="/WEB-INF/view/tiles/default.jsp"&gt;<br />
    &lt;put-attribute name="header" value="/WEB-INF/view/tiles/def_header.jsp" /&gt;<br />
    &lt;put-attribute name="menu" value="/WEB-INF/view/tiles/def_menu.jsp" /&gt;<br />
    &lt;put-attribute name="footer" value="/WEB-INF/view/tiles/def_footer.jsp" /&gt;<br />
  &lt;/definition&gt;<br />
  &lt;definition name="test_main" extends="defaultTemplate"&gt;<br />
    &lt;put-attribute name="content"   value="/WEB-INF/view/test/test_main.jsp"/&gt;<br />
  &lt;/definition&gt;<br />
&lt;/tiles-definitions&gt;</code></p>
<p><strong>6. message.properties</strong><br />
<code># Page titles<br />
index.title=Test Spring MVC + Tiles</code></p>
<p><strong>7. default.jsp</strong><br />
<code>&lt;%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %&gt;<br />
&lt;%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %&gt;<br />
&lt;%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %&gt;<br />
&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"<br />
    pageEncoding="ISO-8859-1"%&gt;<br />
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;<br />
&lt;title&gt;&lt;fmt:message key="index.title"/&gt;&lt;/title&gt;<br />
&lt;link rel=stylesheet href="${pageContext.request.contextPath}/css/global.css" type="text/css"&gt;<br />
&lt;script type="text/javascript" src="${pageContext.request.contextPath}/scripts/global.js"&gt;&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;div id="header"&gt;<br />
    &lt;div id="headerTitle"&gt;&lt;tiles:insertAttribute name="header" /&gt;&lt;/div&gt;<br />
&lt;/div&gt;<br />
&lt;div id="menu"&gt;<br />
    &lt;tiles:insertAttribute name="menu" /&gt;<br />
&lt;/div&gt;<br />
&lt;div id="content"&gt;<br />
    &lt;tiles:insertAttribute name="content" /&gt;<br />
&lt;/div&gt;<br />
&lt;div id="footer"&gt;<br />
    &lt;tiles:insertAttribute name="footer" /&gt;<br />
&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</code></p>
]]></content:encoded>
			<wfw:commentRss>http://technote.wsjoung.com/2009/12/13/spring-mvc-tiles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SwingWorker not on Java 6.0</title>
		<link>http://technote.wsjoung.com/2008/04/24/swingworker-not-on-java-60/</link>
		<comments>http://technote.wsjoung.com/2008/04/24/swingworker-not-on-java-60/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 14:15:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[SwingWorker]]></category>

		<guid isPermaLink="false">http://wsjoung.wordpress.com/?p=84</guid>
		<description><![CDATA[SwingWorker is useful when a time-consuming task has to be performed following a user-interaction event (for example, parsing a huge XML File, on pressing a Button). The most straightforward way to do it is : [sourcecode language='java'] private Document doc; &#8230; JButton button = new JButton(&#8220;Open XML&#8221;); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { [...]]]></description>
			<content:encoded><![CDATA[<p>SwingWorker is useful when a time-consuming task has to be performed following a user-interaction event (for example, parsing a huge XML File, on pressing a Button). The most straightforward way to do it is :</p>
<p>[sourcecode language='java']<br />
 private Document doc;<br />
 &#8230;<br />
 JButton button = new JButton(&#8220;Open XML&#8221;);<br />
 button.addActionListener(new ActionListener() {<br />
    public void actionPerformed(ActionEvent e) {<br />
       doc = loadXML();<br />
    }<br />
 });<br />
[/sourcecode]</p>
<p>This will work, but unfortunately, the loadXML() method will be called in the same thread as the main Swing thread, so if the method needs time to perform, the GUI will freeze during this time.</p>
<p>[sourcecode language='java']<br />
package com.wsjoung.demo;<br />
import javax.swing.SwingUtilities;</p>
<p>public abstract class SwingWorker {<br />
    // see getValue(), setValue()<br />
    private Object value;<br />
    private Thread thread;</p>
<p>    private static class ThreadVar {<br />
        private Thread thread;<br />
        ThreadVar(Thread t) { thread = t; }<br />
        synchronized Thread get() { return thread; }<br />
        synchronized void clear() { thread = null; }<br />
    }</p>
<p>    private ThreadVar threadVar;</p>
<p>    protected synchronized Object getValue() {<br />
        return value;<br />
    }</p>
<p>    private synchronized void setValue(Object x) {<br />
        value = x;<br />
    }</p>
<p>    public abstract Object construct();</p>
<p>    public void finished() {<br />
    }</p>
<p>    public void interrupt() {<br />
        Thread t = threadVar.get();<br />
        if (t != null) {<br />
            t.interrupt();<br />
        }<br />
        threadVar.clear();<br />
    }</p>
<p>    public Object get() {<br />
        while (true) {<br />
            Thread t = threadVar.get();<br />
            if (t == null) {<br />
                return getValue();<br />
            }<br />
            try {<br />
                t.join();<br />
            }<br />
            catch (InterruptedException e) {<br />
                // propagate<br />
                Thread.currentThread().interrupt();<br />
                return null;<br />
            }<br />
        }<br />
    }</p>
<p>    public SwingWorker() {<br />
        final Runnable doFinished = new Runnable() {<br />
           public void run() { finished(); }<br />
        };</p>
<p>        Runnable doConstruct = new Runnable() {<br />
            public void run() {<br />
                try {<br />
                    setValue(construct());<br />
                }<br />
                finally {<br />
                    threadVar.clear();<br />
                }</p>
<p>              SwingUtilities.invokeLater(doFinished);<br />
            }<br />
        };</p>
<p>        Thread t = new Thread(doConstruct);<br />
        threadVar = new ThreadVar(t);<br />
        t.start();<br />
    }<br />
}<br />
[/sourcecode]</p>
<p><a href="http://java.sun.com/products/jfc/tsc/articles/threads/src/SwingWorker.java">SwingWorker.java</a></p>
<p>[sourcecode language='java']<br />
public class Task{<br />
  public void go() {<br />
      current = 0;<br />
      final SwingWorker worker = new SwingWorker() {<br />
          public Object construct() {<br />
              return new ActualTask();<br />
          }<br />
      };<br />
  }</p>
<p>  class ActualTask {<br />
      ActualTask() {<br />
          try {<br />
              Thread.sleep(1000);<br />
          } catch (InterruptedException e) {}<br />
      }<br />
  }<br />
}<br />
[/sourcecode]</p>
<p>Task.java</p>
]]></content:encoded>
			<wfw:commentRss>http://technote.wsjoung.com/2008/04/24/swingworker-not-on-java-60/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>what&#039;s static?</title>
		<link>http://technote.wsjoung.com/2008/04/14/whats-static/</link>
		<comments>http://technote.wsjoung.com/2008/04/14/whats-static/#comments</comments>
		<pubDate>Mon, 14 Apr 2008 19:31:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Static]]></category>

		<guid isPermaLink="false">http://wsjoung.wordpress.com/?p=79</guid>
		<description><![CDATA[First of all, the meaning of static in java is embedded or belong to a specific class not to its instance, and therefore there is no such static class. There is no such static class Embedded or belong to a specific class Global variable No need to load and create its instance Most of methods [...]]]></description>
			<content:encoded><![CDATA[<p>First of all, the meaning of static in java is embedded or belong to a specific class not to its instance, and therefore there is no such static class.</p>
<ul>
<li>There is no such static class</li>
<li>Embedded or belong to a specific class</li>
<li>Global variable</li>
<li>No need to load and create its instance</li>
</ul>
<p>Most of methods and variables in Math class are static, because those are not need to be instanced in most of cases. we just use return value of PI or max(int a, int b).</p>
<p>class  Bicycle {</p>
<p>private static int numberOfBicycles = 0;<br />
private int id;</p>
<p>public Bicycle() {<br />
id = ++numberOfBicycles;<br />
}</p>
<p>public static int getNumberOfBicycles() {<br />
return numberOfBicycles;<br />
}<br />
public int getID() {<br />
return id;<br />
}</p>
<p>public static void main(String[] args) {<br />
Bicycle b1 = new Bicycle();<br />
Bicycle b2 = new Bicycle();</p>
<p>System.out.println(&#8220;static result    : &#8220;+getNumberOfBicycles());<br />
System.out.println(&#8220;static result : &#8220;+numberOfBicycles);<br />
System.out.println(&#8220;instance result  : &#8220;+b1.getID());<br />
System.out.println(&#8220;instance result  : &#8220;+b2.getID());<br />
}<br />
}</p>
<p>Another characteristic of static is that even if we create instance of a class, jvm does not create instance variables for static resources. in above source code, there is no difference calling b1.getNumberOfBicycles(), b2.getNumberOfBicycles() and just getNumberOfBicycles() or directly numberOfBicycles<br />
that mean we should call static variable with its class name because it&#8217;s belong to it. just like Bicycle.numberOfBicycles or in this example, getNumberOfBicycles() because we have a getter.<br />
otherwise get confused.</p>
]]></content:encoded>
			<wfw:commentRss>http://technote.wsjoung.com/2008/04/14/whats-static/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>DataSource setup on Tomcat</title>
		<link>http://technote.wsjoung.com/2007/09/21/datasource-setup-on-tomcat/</link>
		<comments>http://technote.wsjoung.com/2007/09/21/datasource-setup-on-tomcat/#comments</comments>
		<pubDate>Fri, 21 Sep 2007 20:38:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Server]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Tomcat]]></category>

		<guid isPermaLink="false">http://wsjoung.wordpress.com/2007/09/21/datasource-setup-on-tomcat/</guid>
		<description><![CDATA[1. create META-INF/context.xml &#60;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&#62; &#60;Context docBase=&#8221;e-sports&#8221; path=&#8221;/e-sports&#8221; debug=&#8221;0&#8243; reloadable=&#8221;true&#8221; source=&#8221;org.eclipse.jst.j2ee.server:e-sports&#8221;&#62; &#60;Logger className=&#8221;org.apache.catalina.logger.FileLogger&#8221; prefix=&#8221;e-sports_log.&#8221; suffix=&#8221;.txt&#8221; timestamp=&#8221;true&#8221; /&#62; &#60;Resource name=&#8221;jdbc/myoracle&#8221; auth=&#8221;Container&#8221; type=&#8221;javax.sql.DataSource&#8221; driverClassName=&#8221;oracle.jdbc.driver.OracleDriver&#8221; factory=&#8221;org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory&#8221; url=&#8221;jdbc:oracle:thin:@127.0.0.1:1521:ORA92&#8243; username=&#8221;scott&#8221; password=&#8221;tiger&#8221; maxActive=&#8221;20&#8243; maxIdle=&#8221;10&#8243; maxWait=&#8221;-1&#8243; /&#62; &#60;/Context&#62; 2. test.jsp &#60;%@ page import=&#8221;java.sql.Connection&#8221; %&#62; &#60;%@ page import=&#8221;java.sql.ResultSet&#8221; %&#62; &#60;%@ page import=&#8221;java.sql.SQLException&#8221; %&#62; &#60;%@ page import=&#8221;java.sql.Statement&#8221; %&#62; &#60;%@ page import=&#8221;javax.naming.Context&#8221; %&#62; &#60;%@ [...]]]></description>
			<content:encoded><![CDATA[<p>1. create META-INF/context.xml</p>
<p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;<br />
&lt;Context docBase=&#8221;e-sports&#8221; path=&#8221;/e-sports&#8221; debug=&#8221;0&#8243; reloadable=&#8221;true&#8221;<br />
source=&#8221;org.eclipse.jst.j2ee.server:e-sports&#8221;&gt;<br />
&lt;Logger className=&#8221;org.apache.catalina.logger.FileLogger&#8221;<br />
prefix=&#8221;e-sports_log.&#8221; suffix=&#8221;.txt&#8221; timestamp=&#8221;true&#8221; /&gt;<br />
&lt;Resource name=&#8221;jdbc/myoracle&#8221;<br />
auth=&#8221;Container&#8221;<br />
type=&#8221;javax.sql.DataSource&#8221;<br />
driverClassName=&#8221;oracle.jdbc.driver.OracleDriver&#8221;<br />
factory=&#8221;org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory&#8221;<br />
url=&#8221;jdbc:oracle:thin:@127.0.0.1:1521:ORA92&#8243;<br />
username=&#8221;scott&#8221;<br />
password=&#8221;tiger&#8221;<br />
maxActive=&#8221;20&#8243;<br />
maxIdle=&#8221;10&#8243;<br />
maxWait=&#8221;-1&#8243; /&gt;<br />
&lt;/Context&gt;</p>
<p>2. test.jsp<br />
&lt;%@ page import=&#8221;java.sql.Connection&#8221; %&gt;<br />
&lt;%@ page import=&#8221;java.sql.ResultSet&#8221; %&gt;<br />
&lt;%@ page import=&#8221;java.sql.SQLException&#8221; %&gt;<br />
&lt;%@ page import=&#8221;java.sql.Statement&#8221; %&gt;<br />
&lt;%@ page import=&#8221;javax.naming.Context&#8221; %&gt;<br />
&lt;%@ page import=&#8221;javax.naming.InitialContext&#8221; %&gt;<br />
&lt;%@ page import=&#8221;javax.naming.NamingException&#8221; %&gt;<br />
&lt;%@ page import=&#8221;javax.sql.DataSource&#8221; %&gt;</p>
<p>&lt;%<br />
Context ctx = null;<br />
DataSource source = null;<br />
Connection con = null;</p>
<p>try {<br />
ctx = new InitialContext();<br />
ctx = (Context) ctx.lookup(&#8220;java:comp/env&#8221;);<br />
source = (DataSource) ctx.lookup(&#8220;jdbc/myoracle&#8221;);</p>
<p>System.out.println(&#8220;DataSource   ===========================&#8221;+ source);</p>
<p>con = source.getConnection();<br />
System.out.println(&#8220;Connection ============================&#8221;+ con);<br />
} catch (NamingException ne) {<br />
ne.printStackTrace();<br />
}<br />
%&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://technote.wsjoung.com/2007/09/21/datasource-setup-on-tomcat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Signed java applet</title>
		<link>http://technote.wsjoung.com/2007/05/15/signed-java-applet/</link>
		<comments>http://technote.wsjoung.com/2007/05/15/signed-java-applet/#comments</comments>
		<pubDate>Tue, 15 May 2007 17:43:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Applet]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://wsjoung.wordpress.com/2007/05/15/signed-java-applet/</guid>
		<description><![CDATA[Applet Security Basics Below are the basic facts regarding applet security and Java Plug-in. More detail can be found in the next chapter, How RSA Signed Applet Verification Works in Java Plug-in. All unsigned applets are run under the standard applet security model. If usePolicy IS NOT DEFINED in the java.policy file, then a signed [...]]]></description>
			<content:encoded><![CDATA[<h2>Applet Security Basics</h2>
<p>Below are the basic facts regarding applet security and Java Plug-in. More    detail can be found in the next chapter, <a href="http://java.sun.com/j2se/1.5.0/docs/guide/plugin/developer_guide/rsa_how.html">How RSA Signed    Applet Verification Works in Java Plug-in</a>.</p>
<ul>
<li>All <span style="text-decoration:underline;">unsigned applets</span> are run under the standard applet security model.</li>
<li>If <a href="http://java.sun.com/j2se/1.5.0/docs/guide/plugin/developer_guide/rsa_how.html#use">usePolicy</a> IS NOT DEFINED in the java.policy file, then a <span style="text-decoration:underline;">signed applet</span> has the AllPermission permission if:<br />
Java Plug-in can verify the signers, and the user, when prompted, agrees to granting the AllPermission permission.</li>
<li>If usePolicy IS DEFINED, then a <span style="text-decoration:underline;">signed applet</span> has only the permissions defined in java.policy and no prompting occurs.</li>
</ul>
<p>Moreover, note that Java Plug-in now handles certificate management; i.e.,    the certificate verification task is no longer passed off to the browser.</p>
<p>keytool -genkey -keyalg rsa -alias MyCert<br />
keytool -certreq -alias MyCert<br />
keytool -import -alias MyCert -file VSSStanleyNew.cer</p>
<p>or</p>
<p>keytool -selfcert</p>
<p>and</p>
<p>jarsigner AppletName.jar MyCert<br />
jarsigner -verify -verbose -certs AppletName.jar</p>
<ul>
<li><a href="http://java.sun.com/j2se/1.5.0/docs/guide/plugin/developer_guide/contents.html">Java Plugin guide</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://technote.wsjoung.com/2007/05/15/signed-java-applet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eclipse web.xml validation problem</title>
		<link>http://technote.wsjoung.com/2007/02/07/eclipse-webxml-validation-problem/</link>
		<comments>http://technote.wsjoung.com/2007/02/07/eclipse-webxml-validation-problem/#comments</comments>
		<pubDate>Wed, 07 Feb 2007 02:43:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Bug]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://wsjoung.wordpress.com/2007/02/07/eclipse-webxml-validation-problem/</guid>
		<description><![CDATA[The problem is because of &#8220;http://java.sun.com/xml/ns/j2ee/j2ee_1_4.xsd&#8221; fil, it points ibm&#8217;s schema instead of Sun&#8217;s Window -&#62; Preferences&#8230; -&#62; Web and XML -&#62; XML Catalog URI : http://java.sun.com/xml/ns/j2ee/j2ee_web_services_client_1_1.xsd Key Type : Schema Location Key : http://www.ibm.com/webservices/xsd/j2ee_web_services_client_1_1.xsd Thanks Carey Evans]]></description>
			<content:encoded><![CDATA[<p>The problem is because of &#8220;http://java.sun.com/xml/ns/j2ee/j2ee_1_4.xsd&#8221; fil, it points ibm&#8217;s schema instead of Sun&#8217;s</p>
<p>Window -&gt; Preferences&#8230; -&gt; Web and XML -&gt; XML Catalog</p>
<p>URI           : http://java.sun.com/xml/ns/j2ee/j2ee_web_services_client_1_1.xsd<br />
Key Type : Schema Location<br />
Key           : http://www.ibm.com/webservices/xsd/j2ee_web_services_client_1_1.xsd</p>
<p>Thanks Carey Evans</p>
]]></content:encoded>
			<wfw:commentRss>http://technote.wsjoung.com/2007/02/07/eclipse-webxml-validation-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java SE 6 Key Features</title>
		<link>http://technote.wsjoung.com/2006/12/13/java-se-6-key-features/</link>
		<comments>http://technote.wsjoung.com/2006/12/13/java-se-6-key-features/#comments</comments>
		<pubDate>Wed, 13 Dec 2006 06:54:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Features]]></category>

		<guid isPermaLink="false">http://wsjoung.wordpress.com/2006/12/13/java-se-6-key-features/</guid>
		<description><![CDATA[New Security Features and Enhancements Native platform Security (GSS/Kerberos) integration. Java Authentication and Authorization Service (JAAS) login module that employs LDAP authentication New Smart Card I/O API » Find out more Integrated Web Services New API for XML digital signature services for secure web services New Client and Core Java Architecture for XML-Web Services (JAX-WS) [...]]]></description>
			<content:encoded><![CDATA[<p><strong>New Security Features and Enhancements</strong></p>
<p><span class="sp10"> </span></p>
<ul>
<li>Native platform Security (GSS/Kerberos) integration.</li>
<li>Java Authentication and Authorization Service (JAAS) login module that employs LDAP authentication</li>
<li>New Smart Card I/O API<br />
<span class="rightarrowblue">»</span> <a href="http://java.sun.com/developer/technicalArticles/J2SE/security/">Find out more</a></li>
</ul>
<p><span class="sp10"> </span><br />
<strong>Integrated Web Services</strong></p>
<p><span class="sp10"> </span></p>
<ul>
<li>New API for XML digital signature services for secure web services</li>
<li>New Client and Core Java Architecture for XML-Web Services (JAX-WS) 2.0 APIs</li>
<li>New support for Java Architecture for XML Binding (JAXB) 2.0<br />
<span class="rightarrowblue">»</span> <a href="http://java.sun.com/developer/technicalArticles/J2SE/jax_ws_2/">Find out more</a></li>
</ul>
<p><span class="sp10"> </span><br />
<strong>Scripting Language Support (<a href="http://jcp.org/en/jsr/detail?id=223" target="_blank">JSR 223</a>)</strong></p>
<p><span class="sp10"> </span></p>
<ul>
<li>New framework and API for scripting languages</li>
<li>Mozilla Rhino engine for JavaScript built into the platform<br />
<span class="rightarrowblue">»</span> <a href="http://java.sun.com/developer/technicalArticles/J2SE/Desktop/scripting/">Find out more</a></li>
</ul>
<p><span class="sp10"> </span><br />
<strong>Enhanced Management and Serviceability</strong></p>
<p><span class="sp10"> </span></p>
<ul>
<li>Improved JMX Monitoring API</li>
<li>Runtime Support for dTrace (Solaris 10 and future Solaris OS releases only)</li>
<li>Improved memory usage analysis and leak detection<br />
<span class="rightarrowblue">»</span> <a href="http://java.sun.com/developer/technicalArticles/J2SE/monitoring/">Find out more</a></li>
</ul>
<p><span class="sp10"> </span><br />
<strong>Increased Developer Productivity</strong></p>
<p><span class="sp10"> </span></p>
<ul>
<li>JDBC 4.0 support (<a href="http://jcp.org/en/jsr/detail?id=221" target="_blank">JSR 221</a>)</li>
<li>Significant library improvements</li>
<li>Improvements to the Java Platform Debug Architecture (JPDA) &amp; JVM Tool Interface</li>
</ul>
<p><span class="sp10"> </span><br />
<strong>Improved User Experience</strong></p>
<p><span class="sp10"> </span></p>
<ul>
<li>look-and-feel updates to better match underlying operating system</li>
<li>Improved desktop performance and integration</li>
<li>Enhanced internationalization support</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://technote.wsjoung.com/2006/12/13/java-se-6-key-features/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>String constant pool</title>
		<link>http://technote.wsjoung.com/2006/11/26/string-constant-pool/</link>
		<comments>http://technote.wsjoung.com/2006/11/26/string-constant-pool/#comments</comments>
		<pubDate>Sun, 26 Nov 2006 23:50:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[String]]></category>

		<guid isPermaLink="false">http://wsjoung.wordpress.com/2006/11/26/string-constant-pool/</guid>
		<description><![CDATA[Everybody knows about String constant pool which is for efficient memory management in java. Basically most of objects are managed on heap area but String object. In most of ordinary application, programmers use String object quite often and this String object quite frequently need to be changed or it occupies large amounts of memory. Therefore [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal">Everybody knows about String constant pool which is for efficient memory management in java. Basically most of objects are managed on heap area but String object. In most of ordinary application, programmers use String object quite often and this String object quite frequently need to be changed or it occupies large amounts of memory. Therefore instead of managing String object on heap area, they introduced String constant pool.</p>
<p class="MsoNormal">One of important characteristic of String constant pool is that it doesn’t create same String object if there is already String constant in the pool.</p>
<p class="MsoNormal"><code>String var1 = “This is String Literal”;<br />
String var2 = “This is String Literal”;</code></p>
<p class="MsoNormal">For above two String objects, JVM creates only one object in the String constant pool and for the second string reference variable (var2), it points the string object which is created for var1. In this case, (var1 == var2) is true.</p>
<p class="MsoNormal">But one thing, people make confused is that. It works only when it encounter on String Literal with double quote.</p>
<p class="MsoNormal"><code>String var3 = new String(“This is String Literal”);</code></p>
<p class="MsoNormal">In this case, a regular object will be created by new keyword on heap area and it will be placed in the String constant pool. Finally it will be assigned to the reference variable, var3. This process is just by passing from String constant pool management. Therefore, (var1 == var3) is false.</p>
]]></content:encoded>
			<wfw:commentRss>http://technote.wsjoung.com/2006/11/26/string-constant-pool/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>&quot;null&quot;, is this Object or not?</title>
		<link>http://technote.wsjoung.com/2006/11/26/null-is-this-object-or-not/</link>
		<comments>http://technote.wsjoung.com/2006/11/26/null-is-this-object-or-not/#comments</comments>
		<pubDate>Sun, 26 Nov 2006 08:15:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Null]]></category>
		<category><![CDATA[Object]]></category>

		<guid isPermaLink="false">http://wsjoung.wordpress.com/2006/11/26/null-is-this-object-or-not/</guid>
		<description><![CDATA[In java, some people say null is Object and they also use “null object” term when they try to explain something related in null like NullPointerException. And some people simply show “null instanceof Object” result to prove that null is not Object. Of course it returns false for “null instanceof Object”. Because null is technically [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal">In java, some people say null is Object and they also use “null object” term when they try to explain something related in null like NullPointerException.</p>
<p class="MsoNormal">And some people simply show “null instanceof Object” result to prove that null is not Object. Of course it returns false for “null instanceof Object”. Because null is technically not Object.</p>
<p class="MsoNormal">The reason why people keep regarding null as a kind of Object is that they are confused those two terms, Object itself and Reference variable which points an object. Whenever they say “null object”, which means actually reference variable, and that reference variable assigned for a specific bit pattern which is for null.</p>
]]></content:encoded>
			<wfw:commentRss>http://technote.wsjoung.com/2006/11/26/null-is-this-object-or-not/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Read all files in a directory</title>
		<link>http://technote.wsjoung.com/2006/11/17/read-all-files-in-a-directory/</link>
		<comments>http://technote.wsjoung.com/2006/11/17/read-all-files-in-a-directory/#comments</comments>
		<pubDate>Fri, 17 Nov 2006 01:09:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Directory]]></category>
		<category><![CDATA[File]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://wsjoung.wordpress.com/2006/11/17/read-all-files-in-a-directory/</guid>
		<description><![CDATA[int fileCount = 0; File dir = new File(inputDirName); File[] strFilesDirs = dir.listFiles(); if (strFilesDirs == null) { System.err.println(inputDirName +&#8221; is not valid directory name or there is no pdb file&#8221;); System.exit(1); } for (int i=0; i if (strFilesDirs[i].isDirectory()) { //System.out.println(&#8220;Directory: &#8220;+strFilesDirs[i]); } else if (strFilesDirs[i].isFile()) { //System.out.println(&#8220;File: &#8220;+strFilesDirs[i]+&#8221;(&#8220;+strFilesDirs[i].length()+&#8221;)&#8221;); fileCount = fileCount + 1; } [...]]]></description>
			<content:encoded><![CDATA[<p>int fileCount = 0;<br />
File dir = new File(inputDirName);<br />
File[] strFilesDirs = dir.listFiles();</p>
<p>if (strFilesDirs == null) {<br />
System.err.println(inputDirName +&#8221; is not valid directory name or there is no pdb file&#8221;);<br />
System.exit(1);<br />
}<br />
for (int i=0; i<br />
if (strFilesDirs[i].isDirectory()) {<br />
//System.out.println(&#8220;Directory: &#8220;+strFilesDirs[i]);<br />
} else if (strFilesDirs[i].isFile()) {<br />
//System.out.println(&#8220;File: &#8220;+strFilesDirs[i]+&#8221;(&#8220;+strFilesDirs[i].length()+&#8221;)&#8221;);<br />
fileCount = fileCount + 1;<br />
}<br />
}</p>
<p>beside, there is no such method which is changing directory.</p>
]]></content:encoded>
			<wfw:commentRss>http://technote.wsjoung.com/2006/11/17/read-all-files-in-a-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

