register
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:

1.

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


2.

<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"/>
...
</Host>


In the access log, it will look like:


host217-43-97-182.range217-43.btcentralplus.com - - [12/Nov/2007:16:39:48 +0000] "GET /styles/topmenu.css HTTP/1.1" 200 1184 "http://www.jetonrails.com" "
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:

<p>Hello</p>


Solution: put excapteXml="false" in.

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

It will generate source code like:

<p>Hello</p>

And it will show the wording in the browser like:

Hello

Monday, November 05, 2007

Select Distinct Values in XML

For the xml file like below:

<books>
<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" />
</books>

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="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />

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

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;