Heartbreaking news

25 03 2005

The Straits Times, on 24th March 2005, reported a heartbroken guard killing himself. In delivering his findings, the State Coroner said “A love lost can be recovered, but a life lost remains lost.”

How true, a life lost can never be recovered. Let’s all cherish the life that we have today.





JDBC Connection Pooling

15 03 2005

When specifying the driver during database connection pooling, try to use a driver that is inherited from javax.sql.ConnectionPoolDataSource.

For example, in the case of MySQL,
com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource is a more preferred choice than com.mysql.jdbc.Driver.

According to Resin’s documentation, such drivers are easier and more efficient to pool.





How to install cvs server

9 03 2005
  1. Download and unzip CVS source.
  2. Set the environment variable CVSROOT to point to the planned repository directory.
  3. ./configure –prefix=/foo/bar
  4. make
  5. make install
  6. Installation of CVS binary is completed.
  7. Initialise the repository by: /foo/bar/bin/cvs init (ensure that CVSROOT has already been set properly)
  8. Edit /etc/services to add in this line: cvspserver 2401/tcp
  9. Create /etc/xinetd.d/cvspserver:service cvspserver

    {

    socket_type = stream

    protocol = tcp

    wait = no

    user = root

    passenv = PATH

    server = /foo/bar/bin/cvs

    server_args = -f –allow-root=/home/cvsowner/cvsroot pserver

    }

  10. Restart xinetd by sending it the SIGHUP signal: kill -s SIGHUP xinetd_pid
  11. Create $CVSROOT/passwd. Each line of the file must be in the format cvs_username:hashed_password:unix_user




How to submit multiple form elements having the same name in PHP

1 03 2005

In PHP, it is possible to have multiple form elements having the same name. However, the element’s name must be appended with “[]“. For example:

<input type=”text” name=”hoho[]” value=”first element” /><br />
<input type=”text” name=”hoho[]” value=”second element” /><br />
<input type=”text” name=”hoho[]” value=”third element” /><br />

At the processing PHP, the values of the submitted element can be retrieved as an array via:

$myarray = $_POST['hoho']; // Note that the name does not end with “[]” when retrieving
echo $myarray[0];
echo $myarray[1];
echo $myarray[2];





How to input multiple languages in J2EE webapp

1 03 2005
  1. Ensure that the system property file.encoding=UTF-8 is set. In Tomcat’s case, this would mean modifying catalina.sh.
  2. Add response.setContentType(“text/html; charset=UTF-8“) in every Servlet.
  3. Add request.setCharacterEncoding(“UTF-8″) in the form processing JSP/Servlets.
  4. Add <meta equiv=”Content-Type” content=”text/html;charset=utf-8″ /> in the HTML header in every JSP/HTML.
  5. Ensure that the database+table+column has been properly configured to store Unicode.