Thursday, April 23, 2009

Discover the biggest cave in Phong Nha - Ke Bang, Vietnam

The new discovered cave in Vietnam, called Son Doong is considered to be the biggest cave in the world, with the height of 150m and the width of 200m. The previous highest cave belong to Malaysia, called Deer is 100m high and 80m wide. A group of natural scientists from British Royal found this cave after a long journey into the tropical forest in Phong Nha - Ke bang.

More details in http://www.dantri.com.vn

Tuesday, April 21, 2009

How to use unicode resources with <bean:message> tag in Struts 1

Unicode becomes popular in programming. However, in some cases, you cannot use direct Unicode encoding text. The example below is one of those cases.

In the welcome.jsp page, I want to display Korean texts which come from:
- Static text in the source code of welcome.jsp (page encoding = utf-8)
- Message load from properties file using <bean:mesasge> tag
- String bean value get from <bean:write> tag (Unicode string)

I have tried many ways to make all the three strings display correctly but always only two values are displayed correctly. The problem is that <bean:message> writes the value using system default character set (usually ISO-8859-1) Cause I don't understand clearly about i188n multilingual and locale so I cannot find the solution using locale. At last, I found the approach converting from original Unicode encoding to ASCII presentation of Unicode a very convenient way. The conversion can be done by native2ascii tool (come with JDK)

Welcome.jsp

<% @ Taglib uri = "/ tags / struts-bean" prefix = "bean"%>
<% @ Taglib uri = "/ tags / struts-html" prefix = "html"%>
<% @ Taglib uri = "/ tags / struts-logic" prefix = "logic"%>
<% @ Page contentType = "text / html; charset = utf-8" pageEncoding = "utf-8"%>
<html>
<head>
<title> Welcome </ title>
</ head>
<body>
Static <p>: 표제어
<p> Load from resource:
<bean:message key="main.title">
<p> get from server:
<bean:write name="name" scope="session">
</ body>
</ html>

korean_utf8.properties

main.title=표제어

korean_ascii.properties

main.title=\ud45c\uc81c\uc5b4

Sunday, April 19, 2009

How to write log to multiple appenders in log4j


log4j.properties


# TRACE is setting show that all messages will be sent to appender
log4j.rootLogger=TRACE, stdout
log4j.category.AppLogging=TRACE, FILE
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%5p] %d{hh:mm:ss} (%F:%M:%L)%n%m%n%n
log4j.appender.FILE=org.apache.log4j.FileAppender
log4j.appender.FILE.file=log.txt
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=[%5p] %d{hh:mm:ss} (%F:%M:%L)%n%m%n%n
log4j.appender.FILE.append=false
# setting custom level for each appender
log4j.appender.stdout.Threshold=ERROR
log4j.appender.FILE.Threshold=DEBUG

Log4jDemo.java

import org.apache.log4j.Logger;

public class Log4jDemo {
static Logger log = Logger.getLogger("AppLogging");

public static void main(String args[]) {
log.debug("this is my debug message");
log.info("this is my info message");
log.warn("this is my warn message");
log.error("this is my error message");
log.fatal("this is my fatal message");
}
}

Thursday, April 16, 2009

Paracel and Spratly Islands

In my opinion, the conflict of sovereignty in Paracel and Spratly Islands is a difficult topic. Moreover, we don't have enough information to clearly understand the practical situation. So at first, I think we should share our knowledge about Paracel and Spratly Islands, as much as possible. After understanding enough, we can later give wise judgments.
The name Paracel is referred to Hoang Sa and the name Spratly is referred to Truong Sa in Vietnamese. The name South China Sea is referred to Bien Dong in Vietnamese. As you can see in the map, the bold red line depicts the Chinese line of claim of their sovereignty in South China Sea, including Paracel and Spratly Islands. Paracel Islands is near Quang Nam province of Vietnam and Hainan island of China where as Spratly Islands is near the marine front line of Philippines, Brunei and Malaysia. Taiwan, an island country far in the north east also declares their sovereignty of some islands.

You guys can have a look at this link http://www.spratlys.org At least, Peking shows that they have a good preparation to propagate their sovereignty in South China Sea. If one goes to Google and search the keyword "Spratly Islands" , this site comes at the top ten results.