other register

Monday, November 12, 2007

Enable logging remote host name is tomcat access log.

To enable remote host name to be logged in tomcat access log, in conf/server.xml, you have to do two things:


<Service name="Catalina">
<Connector port="8080" ... enableLookups="true"..>


<Host name="localhost" ..>
<Valve className="org.apache.catalina.valves.FastCommonAccessLogValve"
directory="logs" prefix="access_log." suffix=".txt"
pattern="combined" resolveHosts="true" rotatable="true" fileDateFormat="yyyy-MM-dd"/>

In the access log, it will look like: - - [12/Nov/2007:16:39:48 +0000] "GET /styles/topmenu.css HTTP/1.1" 200 1184 "" "
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1)"

The first part is the remote host name instead of remote IP address.

Friday, November 09, 2007

Escape xml in JSTL

For <c:out> in JSTL:

<c:out value="<p>Hello</p>"/>

It will generate source code like:

& lt;p& gt;hello& lt;/p& gt;

And it will show the wording in the browser like:


Solution: put excapteXml="false" in.

<c:out escapexml="false" value="<p>Hello</p>"/>

It will generate source code like:


And it will show the wording in the browser like:


Monday, November 05, 2007

Select Distinct Values in XML

For the xml file like below:

<book author="Kevin Williams" title="Professional XML 2.0" />
<book author="Lewis Carroll" title="Alice in Wonderland" />
<book author="Lewis Carroll" title="Through the Looking-Glass" />

If you want to select distinct author from it, then make sure you use: xslt 2.0, and SaxonBB parser (in OxygenXML for example)

<xsl:stylesheet version="2.0" xmlns:xsl="">
<xsl:output method="xml" indent="yes" />

<xsl:template match="units">
<xsl:for-each select="distinct-values(unit_instance/lev_code)">
<xsl:value-of select="."/>

Thursday, November 01, 2007

Link spans two lines.

If a link spans two lines and looks terrible, then use the following code in the CSS.

line-height: 14pt;