<?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:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>{Complexity}</title>
	<atom:link href="http://technote.wsjoung.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://technote.wsjoung.com</link>
	<description>Simple Tech Note</description>
	<pubDate>Fri, 09 May 2008 21:20:52 +0000</pubDate>
	<generator>http://wordpress.org/?v=MU</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Incremental backup scripts</title>
		<link>http://technote.wsjoung.com/2008/05/09/incremental-backup-scripts/</link>
		<comments>http://technote.wsjoung.com/2008/05/09/incremental-backup-scripts/#comments</comments>
		<pubDate>Fri, 09 May 2008 21:20:52 +0000</pubDate>
		<dc:creator>wsjoung</dc:creator>
		
		<category><![CDATA[System]]></category>

		<category><![CDATA[Backup]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://wsjoung.wordpress.com/?p=92</guid>
		<description><![CDATA[#!/bin/bash
#
# creates backups of essential files
#
DATA="/home /root /usr/local/httpd"
CONFIG="/etc /var/lib /var/named"
LIST="/tmp/backlist_$$.txt"
#
mount /mnt/backup
set $(date)
#
if test "$1" = "Sun" ; then
        # weekly a full backup of all data and config. settings:
        tar cfz "/mnt/backup/data/data_full_$6-$2-$3.tgz" $DATA
        rm [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><pre>#!/bin/bash
#
# creates backups of essential files
#
DATA="/home /root /usr/local/httpd"
CONFIG="/etc /var/lib /var/named"
LIST="/tmp/backlist_$$.txt"
#
mount /mnt/backup
set $(date)
#
if test "$1" = "Sun" ; then
        # weekly a full backup of all data and config. settings:
        tar cfz "/mnt/backup/data/data_full_$6-$2-$3.tgz" $DATA
        rm -f /mnt/backup/data/data_diff*
        #
        tar cfz "/mnt/backup/config/config_full_$6-$2-$3.tgz" $CONFIG
        rm -f /mnt/backup/config/config_diff*
else
        # incremental backup:
        find $DATA -depth -type f \( -ctime -1 -o -mtime -1 \) -print &gt; $LIST
        tar cfzT "/mnt/backup/data/data_diff_$6-$2-$3.tgz" "$LIST"
        rm -f "$LIST"
        #
        find $CONFIG -depth -type f  \( -ctime -1 -o -mtime -1 \) -print &gt; $LIST
        tar cfzT "/mnt/backup/config/config_diff_$6-$2-$3.tgz" "$LIST"
        rm -f "$LIST"
fi
#
# create sql dump of databases:
mysqldump -u root --password=mypass --opt mydb &gt; "/mnt/backup/database/mydb_$6-$2-$3.sql"
gzip "/mnt/backup/database/mydb_$6-$2-$3.sql"
#
umount /mnt/backup
</pre>
<p><a href="http://www.xs4all.nl/~voorburg/backup.html">&gt;&gt; Backup script for Linux using tar and find</a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/wsjoung.wordpress.com/92/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/wsjoung.wordpress.com/92/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/wsjoung.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/wsjoung.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/wsjoung.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/wsjoung.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/wsjoung.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/wsjoung.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/wsjoung.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/wsjoung.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/wsjoung.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/wsjoung.wordpress.com/92/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=technote.wsjoung.com&blog=25269&post=92&subd=wsjoung&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://technote.wsjoung.com/2008/05/09/incremental-backup-scripts/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/wsjoung-128.jpg" medium="image">
			<media:title type="html">wsjoung</media:title>
		</media:content>
	</item>
		<item>
		<title>How to attach a new hard disk to ubuntu linux</title>
		<link>http://technote.wsjoung.com/2008/05/08/how-to-attach-a-new-hard-disk-to-ubuntu-linux/</link>
		<comments>http://technote.wsjoung.com/2008/05/08/how-to-attach-a-new-hard-disk-to-ubuntu-linux/#comments</comments>
		<pubDate>Thu, 08 May 2008 14:31:37 +0000</pubDate>
		<dc:creator>wsjoung</dc:creator>
		
		<category><![CDATA[System]]></category>

		<category><![CDATA[Config]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://wsjoung.wordpress.com/?p=91</guid>
		<description><![CDATA[root@server-tribeca:/etc# fdisk -l
Disk /dev/sda: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0&#215;9dc96e9e
Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *  [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><strong>root@server-tribeca:/etc# fdisk -l</strong></p>
<p>Disk /dev/sda: 40.0 GB, 40020664320 bytes<br />
255 heads, 63 sectors/track, 4865 cylinders<br />
Units = cylinders of 16065 * 512 = 8225280 bytes<br />
Disk identifier: 0&#215;9dc96e9e</p>
<p>Device Boot      Start         End      Blocks   Id  System<br />
/dev/sda1   *           1        4689    37664361   83  Linux<br />
/dev/sda2            4690        4865     1413720    5  Extended<br />
/dev/sda5            4690        4865     1413688+  82  Linux swap / Solaris</p>
<p>Disk /dev/sdb: 120.0 GB, 120034123776 bytes<br />
255 heads, 63 sectors/track, 14593 cylinders<br />
Units = cylinders of 16065 * 512 = 8225280 bytes<br />
Disk identifier: 0&#215;00a080f4</p>
<p>Device Boot      Start         End      Blocks   Id  System<br />
/dev/sdb1   *           1          13      104391   83  Linux<br />
/dev/sdb2              14       14471   116133885   83  Linux<br />
/dev/sdb3           14472       14593      979965   82  Linux swap / Solaris</p>
<p><strong>root@server-tribeca:/etc# fdisk /dev/sdb</strong></p>
<p>The number of cylinders for this disk is set to 14593.<br />
There is nothing wrong with that, but this is larger than 1024,<br />
and could in certain setups cause problems with:<br />
1) software that runs at boot time (e.g., old versions of LILO)<br />
2) booting and partitioning software from other OSs<br />
(e.g., DOS FDISK, OS/2 FDISK)</p>
<p>Command (m for help): <strong>d</strong><br />
Partition number (1-4): <strong>1</strong></p>
<p>Command (m for help): <strong>d</strong><br />
Partition number (1-4): <strong>2</strong></p>
<p>Command (m for help): <strong>d</strong><br />
Selected partition 3</p>
<p>Command (m for help): <strong>d</strong><br />
No partition is defined yet!</p>
<p>Command (m for help): <strong>n</strong><br />
Command action<br />
e   extended<br />
p   primary partition (1-4)<br />
<strong> p</strong><br />
Partition number (1-4): <strong>1</strong><br />
First cylinder (1-14593, default 1): <strong>1</strong><br />
Last cylinder or +size or +sizeM or +sizeK (1-14593, default 14593):<br />
Using default value 14593</p>
<p>Command (m for help): <strong>w</strong><br />
The partition table has been altered!</p>
<p>Calling ioctl() to re-read partition table.<br />
Syncing disks.</p>
<p><strong>root@server-tribeca:/etc# mkfs.ext3 /dev/sdb1</strong><br />
mke2fs 1.40.8 (13-Mar-2008)<br />
Filesystem label=<br />
OS type: Linux<br />
Block size=4096 (log=2)<br />
Fragment size=4096 (log=2)<br />
7331840 inodes, 29304560 blocks<br />
1465228 blocks (5.00%) reserved for the super user<br />
First data block=0<br />
Maximum filesystem blocks=0<br />
895 block groups<br />
32768 blocks per group, 32768 fragments per group<br />
8192 inodes per group<br />
Superblock backups stored on blocks:<br />
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,<br />
4096000, 7962624, 11239424, 20480000, 23887872</p>
<p>Writing inode tables: done<br />
Creating journal (32768 blocks): done<br />
Writing superblocks and filesystem accounting information: done</p>
<p>This filesystem will be automatically checked every 22 mounts or<br />
180 days, whichever comes first.  Use tune2fs -c or -i to override.</p>
<p><strong>root@server-tribeca:/etc# ls /dev/disk/by-uuid -alh</strong><br />
lrwxrwxrwx 1 root root  10 2008-05-07 17:58 753a86d9-6228-4725-a9ae-6f457c2b1824 -&gt; ../../sdb1<br />
lrwxrwxrwx 1 root root  10 2008-05-07 17:58 dbd44197-c1c5-427d-9a34-40f652b92f42 -&gt; ../../sda1<br />
lrwxrwxrwx 1 root root  10 2008-05-07 17:58 e15f5c2c-fc1f-414d-8c67-99c567f44d6a -&gt; ../../sda5</p>
<p><strong>root@server-tribeca:/etc# mkdir /disk1</strong></p>
<p><strong>root@server-tribeca:/etc# vi /etc/fstab</strong><br />
# /etc/fstab: static file system information.<br />
#<br />
# &lt;file system&gt; &lt;mount point&gt;   &lt;type&gt;  &lt;options&gt;       &lt;dump&gt;  &lt;pass&gt;<br />
proc            /proc           proc    defaults        0       0<br />
# /dev/sda1<br />
UUID=dbd44197-c1c5-427d-9a34-40f652b92f42 /               ext3    relatime,errors=remount-ro 0       1<br />
# /dev/sda5<br />
UUID=e15f5c2c-fc1f-414d-8c67-99c567f44d6a none            swap    sw              0       0<br />
/dev/scd0       /media/cdrom0   udf,iso9660 user,noauto,exec,utf8 0       0<br />
/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0       0<br />
<strong> UUID=753a86d9-6228-4725-a9ae-6f457c2b1824 /disk1          ext3    defaults,errors=remount-ro 0       1</strong></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/wsjoung.wordpress.com/91/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/wsjoung.wordpress.com/91/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/wsjoung.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/wsjoung.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/wsjoung.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/wsjoung.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/wsjoung.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/wsjoung.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/wsjoung.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/wsjoung.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/wsjoung.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/wsjoung.wordpress.com/91/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=technote.wsjoung.com&blog=25269&post=91&subd=wsjoung&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://technote.wsjoung.com/2008/05/08/how-to-attach-a-new-hard-disk-to-ubuntu-linux/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/wsjoung-128.jpg" medium="image">
			<media:title type="html">wsjoung</media:title>
		</media:content>
	</item>
		<item>
		<title>Changing Timezon and NTP On Ubuntu server</title>
		<link>http://technote.wsjoung.com/2008/05/05/changing-timezon-and-ntp-on-ubuntu-server/</link>
		<comments>http://technote.wsjoung.com/2008/05/05/changing-timezon-and-ntp-on-ubuntu-server/#comments</comments>
		<pubDate>Mon, 05 May 2008 22:06:00 +0000</pubDate>
		<dc:creator>wsjoung</dc:creator>
		
		<category><![CDATA[System]]></category>

		<category><![CDATA[Config]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://wsjoung.wordpress.com/?p=90</guid>
		<description><![CDATA[Timezon Config
dpkg-reconfigure tzdata
Time Synchronisation with NTP
as root, create a file /etc/cron.daily/ntpdate  containing:
ntpdate ntp.ubuntu.com
The file /etc/cron.daily/ntpdate must also be executable
sudo chmod 755 /etc/cron.daily/ntpdate
       ]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><em><strong>Timezon Config</strong></em></p>
<p>dpkg-reconfigure tzdata</p>
<p><em><strong>Time Synchronisation with NTP</strong></em></p>
<p>as root, create a file /etc/cron.daily/ntpdate  containing:<br />
ntpdate ntp.ubuntu.com<br />
The file <code>/etc/cron.daily/ntpdate</code> must also be executable<br />
sudo chmod 755 /etc/cron.daily/ntpdate</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/wsjoung.wordpress.com/90/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/wsjoung.wordpress.com/90/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/wsjoung.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/wsjoung.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/wsjoung.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/wsjoung.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/wsjoung.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/wsjoung.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/wsjoung.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/wsjoung.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/wsjoung.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/wsjoung.wordpress.com/90/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=technote.wsjoung.com&blog=25269&post=90&subd=wsjoung&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://technote.wsjoung.com/2008/05/05/changing-timezon-and-ntp-on-ubuntu-server/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/wsjoung-128.jpg" medium="image">
			<media:title type="html">wsjoung</media:title>
		</media:content>
	</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>wsjoung</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 :


 private Document doc;
 ...
 JButton button = new JButton(&#34;Open XML&#34;);
 button.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><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>
<pre name="code" class="java">

 private Document doc;
 ...
 JButton button = new JButton(&quot;Open XML&quot;);
 button.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
       doc = loadXML();
    }
 });
</pre>
<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>
<pre name="code" class="java">

package com.wsjoung.demo;
import javax.swing.SwingUtilities;

public abstract class SwingWorker {
    // see getValue(), setValue()
    private Object value;
    private Thread thread;

    private static class ThreadVar {
        private Thread thread;
        ThreadVar(Thread t) { thread = t; }
        synchronized Thread get() { return thread; }
        synchronized void clear() { thread = null; }
    }

    private ThreadVar threadVar;

    protected synchronized Object getValue() {
        return value;
    }

    private synchronized void setValue(Object x) {
        value = x;
    }

    public abstract Object construct();

    public void finished() {
    }

    public void interrupt() {
        Thread t = threadVar.get();
        if (t != null) {
            t.interrupt();
        }
        threadVar.clear();
    }

    public Object get() {
        while (true) {
            Thread t = threadVar.get();
            if (t == null) {
                return getValue();
            }
            try {
                t.join();
            }
            catch (InterruptedException e) {
                // propagate
                Thread.currentThread().interrupt();
                return null;
            }
        }
    }

    public SwingWorker() {
        final Runnable doFinished = new Runnable() {
           public void run() { finished(); }
        };

        Runnable doConstruct = new Runnable() {
            public void run() {
                try {
                    setValue(construct());
                }
                finally {
                    threadVar.clear();
                }

              SwingUtilities.invokeLater(doFinished);
            }
        };

        Thread t = new Thread(doConstruct);
        threadVar = new ThreadVar(t);
        t.start();
    }
}
</pre>
<p><a href="http://java.sun.com/products/jfc/tsc/articles/threads/src/SwingWorker.java">SwingWorker.java</a></p>
<pre name="code" class="java">

public class Task{
  public void go() {
      current = 0;
      final SwingWorker worker = new SwingWorker() {
          public Object construct() {
              return new ActualTask();
          }
      };
  }

  class ActualTask {
      ActualTask() {
          try {
              Thread.sleep(1000);
          } catch (InterruptedException e) {}
      }
  }
}
</pre>
<p>Task.java</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/wsjoung.wordpress.com/84/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/wsjoung.wordpress.com/84/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/wsjoung.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/wsjoung.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/wsjoung.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/wsjoung.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/wsjoung.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/wsjoung.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/wsjoung.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/wsjoung.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/wsjoung.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/wsjoung.wordpress.com/84/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=technote.wsjoung.com&blog=25269&post=84&subd=wsjoung&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://technote.wsjoung.com/2008/04/24/swingworker-not-on-java-60/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/wsjoung-128.jpg" medium="image">
			<media:title type="html">wsjoung</media:title>
		</media:content>
	</item>
		<item>
		<title>pure-ftpd-mysql, [ERROR] Home directory not available - aborting</title>
		<link>http://technote.wsjoung.com/2008/04/15/pure-ftpd-mysql-error-home-directory-not-available-aborting/</link>
		<comments>http://technote.wsjoung.com/2008/04/15/pure-ftpd-mysql-error-home-directory-not-available-aborting/#comments</comments>
		<pubDate>Tue, 15 Apr 2008 15:49:22 +0000</pubDate>
		<dc:creator>wsjoung</dc:creator>
		
		<category><![CDATA[System]]></category>

		<category><![CDATA[Config]]></category>

		<category><![CDATA[FTP]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Server]]></category>

		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://wsjoung.wordpress.com/?p=80</guid>
		<description><![CDATA[groupadd -g 2001 ftpgroup
useradd -u 2001 -s /bin/false -d /bin/null -c &#8220;pureftpd user&#8221; -g ftpgroup ftpuser
Instead of this dummy ftpuser account setting when they want to create real linux account.
they may get this error &#8220;Home directory not available - abort&#8221; even if they set CreateHomeDir to yes.
Solution:
the last existing in the home path should be [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>groupadd -g 2001 ftpgroup<br />
useradd -u 2001 -s /bin/false -d /bin/null -c &#8220;pureftpd user&#8221; -g ftpgroup ftpuser</p>
<p>Instead of this dummy ftpuser account setting when they want to create real linux account.<br />
they may get this error &#8220;Home directory not available - abort&#8221; even if they set CreateHomeDir to yes.</p>
<p>Solution:<br />
the last existing in the home path should be own by root.<br />
for example, we want to create somebody&#8217;s home directory when he log in, /home/ftpuser/somebody<br />
then the last existing directory &#8216;ftpuer&#8217; may look like this,<br />
drwxr-xr-x 2 <strong>root</strong> ftpgroup 4096 2008-04-15 11:20 ftpuser</p>
<p><a href="http://ecartis.ausics.net/hypermail/pure-old/0171.html">[pure-ftpd] CreateHomeDir problem (&#8221;[ERROR] Home directory not available - aborting&#8221;)</a><br />
<a href="http://howtoforge.com/virtual-hosting-with-pureftpd-and-mysql-ubuntu-7.10">Virtual Hosting With PureFTPd And MySQL (Incl. Quota And Bandwidth Management) On Ubuntu 7.10 (Gutsy Gibbon)</a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/wsjoung.wordpress.com/80/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/wsjoung.wordpress.com/80/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/wsjoung.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/wsjoung.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/wsjoung.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/wsjoung.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/wsjoung.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/wsjoung.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/wsjoung.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/wsjoung.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/wsjoung.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/wsjoung.wordpress.com/80/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=technote.wsjoung.com&blog=25269&post=80&subd=wsjoung&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://technote.wsjoung.com/2008/04/15/pure-ftpd-mysql-error-home-directory-not-available-aborting/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/wsjoung-128.jpg" medium="image">
			<media:title type="html">wsjoung</media:title>
		</media:content>
	</item>
		<item>
		<title>what&#8217;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>wsjoung</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 and variables in Math class [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><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(&#8221;static result    : &#8220;+getNumberOfBicycles());<br />
System.out.println(&#8221;static result : &#8220;+numberOfBicycles);<br />
System.out.println(&#8221;instance result  : &#8220;+b1.getID());<br />
System.out.println(&#8221;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>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/wsjoung.wordpress.com/79/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/wsjoung.wordpress.com/79/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/wsjoung.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/wsjoung.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/wsjoung.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/wsjoung.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/wsjoung.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/wsjoung.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/wsjoung.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/wsjoung.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/wsjoung.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/wsjoung.wordpress.com/79/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=technote.wsjoung.com&blog=25269&post=79&subd=wsjoung&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://technote.wsjoung.com/2008/04/14/whats-static/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/wsjoung-128.jpg" medium="image">
			<media:title type="html">wsjoung</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL Style, Theta vs. ANSI</title>
		<link>http://technote.wsjoung.com/2008/04/11/theta-style-vs-ansi-style/</link>
		<comments>http://technote.wsjoung.com/2008/04/11/theta-style-vs-ansi-style/#comments</comments>
		<pubDate>Fri, 11 Apr 2008 21:13:30 +0000</pubDate>
		<dc:creator>wsjoung</dc:creator>
		
		<category><![CDATA[Database]]></category>

		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://wsjoung.wordpress.com/?p=78</guid>
		<description><![CDATA[Theta Style:
SELECT i.order_id, p.product_id, p.name, p.desc
FROM CustomerItem i, Product p
WHERE i.product_id = p.product_id
AND i.order_id = 84463;
ANSI Style:
SELECT i.order_id, p.product_id, p.name, p.desc
FROM CustomerItem i
INNER JOIN Product p ON i.product_id = p.product_id
WHERE i.order_id = 84463;
Sometimes, it&#8217;s hard to realized whether there is other style of SQL. Obviously there are two different SQL style. theta is older and [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><em><strong>Theta Style:</strong></em><br />
SELECT i.order_id, p.product_id, p.name, p.desc<br />
FROM CustomerItem i, Product p<br />
WHERE i.product_id = p.product_id<br />
AND i.order_id = 84463;</p>
<p><em><strong>ANSI Style:</strong></em><br />
SELECT i.order_id, p.product_id, p.name, p.desc<br />
FROM CustomerItem i<br />
INNER JOIN Product p ON i.product_id = p.product_id<br />
WHERE i.order_id = 84463;</p>
<p>Sometimes, it&#8217;s hard to realized whether there is other style of SQL. Obviously there are two different SQL style. theta is older and more obscure but many people still use it.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/wsjoung.wordpress.com/78/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/wsjoung.wordpress.com/78/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/wsjoung.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/wsjoung.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/wsjoung.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/wsjoung.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/wsjoung.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/wsjoung.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/wsjoung.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/wsjoung.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/wsjoung.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/wsjoung.wordpress.com/78/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=technote.wsjoung.com&blog=25269&post=78&subd=wsjoung&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://technote.wsjoung.com/2008/04/11/theta-style-vs-ansi-style/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/wsjoung-128.jpg" medium="image">
			<media:title type="html">wsjoung</media:title>
		</media:content>
	</item>
		<item>
		<title>Amazon interview questions</title>
		<link>http://technote.wsjoung.com/2008/02/06/amazon-interview/</link>
		<comments>http://technote.wsjoung.com/2008/02/06/amazon-interview/#comments</comments>
		<pubDate>Wed, 06 Feb 2008 17:33:23 +0000</pubDate>
		<dc:creator>wsjoung</dc:creator>
		
		<category><![CDATA[Algorithm]]></category>

		<category><![CDATA[Amazon]]></category>

		<category><![CDATA[Interview]]></category>

		<category><![CDATA[Linked List]]></category>

		<guid isPermaLink="false">http://wsjoung.wordpress.com/?p=76</guid>
		<description><![CDATA[
what&#8217;s difference C++ and java
explain about java static
is java use call by reference or call by value
get the algorithm to fine nth value from the last element in single linked list, and write code

all questions look pretty easy though,
anyway, the last algorithm question. because it&#8217;s just one direction single linked list, we should trouble from [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><ul>
<li>what&#8217;s difference C++ and java</li>
<li>explain about java static</li>
<li>is java use call by reference or call by value</li>
<li>get the algorithm to fine nth value from the last element in single linked list, and write code</li>
</ul>
<p>all questions look pretty easy though,</p>
<p>anyway, the last algorithm question. because it&#8217;s just one direction single linked list, we should trouble from the start node to the last node. then we can figure out how many elements in that linked list when we reached the last element. then we can simply travel again from the start node to (m-n)th element. complexity is O(n).<br />
I was trying to bring up some other data structure like stack or hash table but, all those are not good  in terms of space efficiency. we do not have to wast precious resource which doesn&#8217;t increase the performance that much.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/wsjoung.wordpress.com/76/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/wsjoung.wordpress.com/76/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/wsjoung.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/wsjoung.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/wsjoung.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/wsjoung.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/wsjoung.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/wsjoung.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/wsjoung.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/wsjoung.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/wsjoung.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/wsjoung.wordpress.com/76/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=technote.wsjoung.com&blog=25269&post=76&subd=wsjoung&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://technote.wsjoung.com/2008/02/06/amazon-interview/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/wsjoung-128.jpg" medium="image">
			<media:title type="html">wsjoung</media:title>
		</media:content>
	</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>wsjoung</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;%@ page import=&#8221;javax.naming.InitialContext&#8221; %&#62;
&#60;%@ page import=&#8221;javax.naming.NamingException&#8221; %&#62;
&#60;%@ page import=&#8221;javax.sql.DataSource&#8221; %&#62;
&#60;%
Context ctx = null;
DataSource source = null;
Connection con = null;
try {
ctx = new InitialContext();
ctx = (Context) [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><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(&#8221;java:comp/env&#8221;);<br />
source = (DataSource) ctx.lookup(&#8221;jdbc/myoracle&#8221;);</p>
<p>System.out.println(&#8221;DataSource   ===========================&#8221;+ source);</p>
<p>con = source.getConnection();<br />
System.out.println(&#8221;Connection ============================&#8221;+ con);<br />
} catch (NamingException ne) {<br />
ne.printStackTrace();<br />
}<br />
%&gt;</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/wsjoung.wordpress.com/75/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/wsjoung.wordpress.com/75/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/wsjoung.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/wsjoung.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/wsjoung.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/wsjoung.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/wsjoung.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/wsjoung.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/wsjoung.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/wsjoung.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/wsjoung.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/wsjoung.wordpress.com/75/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=technote.wsjoung.com&blog=25269&post=75&subd=wsjoung&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://technote.wsjoung.com/2007/09/21/datasource-setup-on-tomcat/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/wsjoung-128.jpg" medium="image">
			<media:title type="html">wsjoung</media:title>
		</media:content>
	</item>
		<item>
		<title>javamail smtp with Gmail</title>
		<link>http://technote.wsjoung.com/2007/08/03/javamail-smtp-with-gmail/</link>
		<comments>http://technote.wsjoung.com/2007/08/03/javamail-smtp-with-gmail/#comments</comments>
		<pubDate>Fri, 03 Aug 2007 18:29:57 +0000</pubDate>
		<dc:creator>wsjoung</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Gmail]]></category>

		<category><![CDATA[Javamail]]></category>

		<category><![CDATA[Servlet]]></category>

		<category><![CDATA[SMTP]]></category>

		<guid isPermaLink="false">http://wsjoung.wordpress.com/2007/08/03/javamail-smtp-with-gmail/</guid>
		<description><![CDATA[package com.mycompany.emailsender;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.security.Security;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
/**
* Servlet implementation class for Servlet: GmailSender
*
*/
public class GmailSender extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#HttpServlet()
*/
public GmailSender() {
super();
}
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>package com.mycompany.emailsender;</p>
<p>import java.io.IOException;<br />
import javax.servlet.ServletException;<br />
import javax.servlet.http.HttpServletRequest;<br />
import javax.servlet.http.HttpServletResponse;</p>
<p>import java.security.Security;<br />
import java.util.Properties;</p>
<p>import javax.mail.Message;<br />
import javax.mail.MessagingException;<br />
import javax.mail.Session;<br />
import javax.mail.Transport;<br />
import javax.mail.internet.InternetAddress;<br />
import javax.mail.internet.MimeMessage;</p>
<p>/**<br />
* Servlet implementation class for Servlet: GmailSender<br />
*<br />
*/<br />
public class GmailSender extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {<br />
/* (non-Java-doc)<br />
* @see javax.servlet.http.HttpServlet#HttpServlet()<br />
*/<br />
public GmailSender() {<br />
super();<br />
}</p>
<p>/* (non-Java-doc)<br />
* @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)<br />
*/<br />
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {<br />
// TODO Auto-generated method stub<br />
}</p>
<p>/* (non-Java-doc)<br />
* @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)<br />
*/<br />
final String SMTP_HOST_NAME = &#8220;smtp.gmail.com&#8221;;<br />
final int SMTP_HOST_PORT = 465;<br />
final String SMTP_AUTH_USER = &#8220;XXXXXX@gmail.com&#8221;;<br />
final String SMTP_AUTH_PWD  = &#8220;XXXXXX&#8221;;<br />
final String SSL_FACTORY = &#8220;javax.net.ssl.SSLSocketFactory&#8221;;</p>
<p>String emailFromAddress = null;<br />
String[] sendTo = null;<br />
String subject = null;<br />
String content = null;</p>
<p>protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {</p>
<p>Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());</p>
<p>String address = request.getParameter(&#8221;address&#8221;);<br />
sendTo = address.split(&#8221;;&#8221;);</p>
<p>emailFromAddress = request.getParameter(&#8221;sender&#8221;);<br />
this.subject = request.getParameter(&#8221;title&#8221;);<br />
this.content = request.getParameter(&#8221;content&#8221;);</p>
<p>try {<br />
for (int i=0; i&lt;sendTo.length; i++) {<br />
sendSSLMessage(sendTo[i]);<br />
}<br />
System.out.println(&#8221;Sucessfully Sent mail to All Users&#8221;);</p>
<p>} catch (Exception e) {System.out.println(e);}<br />
}</p>
<p>public void sendSSLMessage(String dest) throws MessagingException {</p>
<p>Properties props = new Properties();</p>
<p>props.put(&#8221;mail.transport.protocol&#8221;, &#8220;smtps&#8221;);<br />
props.put(&#8221;mail.smtps.host&#8221;, SMTP_HOST_NAME);<br />
props.put(&#8221;mail.smtps.auth&#8221;, &#8220;true&#8221;);<br />
props.put(&#8221;mail.smtps.quitwait&#8221;, &#8220;false&#8221;);</p>
<p>Session mailSession = Session.getDefaultInstance(props);<br />
mailSession.setDebug(false);<br />
Transport transport = mailSession.getTransport();</p>
<p>MimeMessage message = new MimeMessage(mailSession);<br />
message.setSubject(subject);<br />
InternetAddress addressFrom = new InternetAddress(emailFromAddress);<br />
message.setFrom(addressFrom);<br />
message.setContent(content, &#8220;text/html&#8221;);</p>
<p>message.addRecipient(Message.RecipientType.TO,new InternetAddress(dest));</p>
<p>transport.connect(SMTP_HOST_NAME, SMTP_HOST_PORT, SMTP_AUTH_USER, SMTP_AUTH_PWD);</p>
<p>transport.sendMessage(message,message.getRecipients(Message.RecipientType.TO));<br />
transport.close();<br />
}<br />
}</p>
<p>reference: http://www.rgagnon.com/javadetails/java-0083.html</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/wsjoung.wordpress.com/73/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/wsjoung.wordpress.com/73/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/wsjoung.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/wsjoung.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/wsjoung.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/wsjoung.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/wsjoung.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/wsjoung.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/wsjoung.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/wsjoung.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/wsjoung.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/wsjoung.wordpress.com/73/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=technote.wsjoung.com&blog=25269&post=73&subd=wsjoung&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://technote.wsjoung.com/2007/08/03/javamail-smtp-with-gmail/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/wsjoung-128.jpg" medium="image">
			<media:title type="html">wsjoung</media:title>
		</media:content>
	</item>
	</channel>
</rss>