Displaying keyword search results 1 - 10
Created by Fang on January 28, 2012 13:24:09 Last update: January 28, 2012 13:31:22
This is a simple JSP custom tags library with tag body. Just like the JSF counterpart , it splits a string and repeats the body for each word, i.e., with this markup:
<%@ taglib uri="http://custom.tag.com/demo" prefix...output:
<html> <body> <p>Hello Tigger!</p> <p>H...With Maven, this is the directory structure:
./src ./src/main ./src/main/resources ./s...There are three files to write: pom.xml :
<project xmlns="http://maven.apache.org/POM/4.0.0"...src/main/java/tagdemo/IterateTag.java :
package tagdemo; import java.io.IOException...src/main/resources/META-INF/demotag.tld :
<?xml version="1.0" encoding="UTF-8"?> <!DO...Build with:
mvn clean installTo use it as a dependency in other Maven projects:
<dependency> <groupId>tag-demo</groupId> ...
Created by Fang on November 08, 2011 20:55:00 Last update: November 21, 2011 18:19:44
In the simple taglib example , I used a tag handler class to implement a taglib. This is an example to implement a taglib with a UI component. The purpose is to use a custom tag to split a string and print each part in a separate paragraph, i.e., print
<p>john</p> <p>steve</p> <p>mike</p>with custom tag <my:foreach> :
<my:foreach var="who" value="john steve mike"> ...These are the files: pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"...src/main/java/com/example/UIForeash.java :
package com.example; import java.io.IOExcep...src/main/resources/META-INF/faces-config.xml :
<?xml version="1.0" encoding="UTF-8"?> <faces-c...src/main/resources/META-INF/foreach.taglib.xml :
<?xml version="1.0" encoding="UTF-8"?> <facelet...How to use: Put the JAR file generated by the above project in the WEB-INF/lib folder of the web app. If the web app is a Maven project, just add the taglib project as a dependency:...
Created by freyo on August 31, 2011 15:49:54 Last update: August 31, 2011 15:49:54
Got this error while trying to build Android app:
[apkbuilder] Creating AppInfo-debug-unaligned.ap...Solution: Delete the Android debug keystore:
$ rm ~/.android/debug.keystoreBuild again:
$ ant debugThe new key is valid for 30 years (keystore password is 'android'):
$ keytool -list -v -keystore ~/.android/debug.keys...
Created by nogeek on November 04, 2010 20:00:15 Last update: November 05, 2010 14:38:43
Following are some bugs in the Xalan jar shipped with JBoss 5.1.0 GA and JBoss 6.0. The Xalan jar file is located in jboss-5.1.0.GA/lib/endorsed ( %JBOSS_HOME%/common/lib for JBoss 6.0). Test xml:
<?xml version="1.0" encoding="ISO-8859-1"?> ...Test xsl:
<?xml version="1.0" encoding="ISO-8859-1"?> <xs...XSLT Java code:
import org.w3c.dom.*; import javax.xml.parsers....DateUtil.java
import java.util.Date; public class DateUti...XSLT output:
Transformer Factory class: class org.apache.xalan....Apparently, the output is wrong. The string "A test event" should not have been displayed.
Created by Dr. Xi on August 27, 2010 22:35:53 Last update: August 27, 2010 22:35:53
This example decompresses a gzip compressed file with java.util.zip.GZIPInputStream . The input is assumed to be Base64 encoded after being gzipped (such would be the case when binary data is transmitted within an XML file). You don't need the Base64InputStream if the data is not Base64 encoded.
import java.io.*; import java.util.zip.GZIPInpu...
Created by Dr. Xi on July 19, 2010 21:58:34 Last update: July 23, 2010 21:37:23
Parsing XML in Java is really simple:
import java.io.*; import javax.xml.parsers.Docu...The parser implementation details are hidden behind the JAXP API. In case you want to know which parser implementation is used, this is what the JavaDoc for DocumentBuilderFactory.newInstance says: Use the javax.xml.parsers.DocumentBuilderFactory system property. Use the properties file " lib/jaxp.properties " in the JRE directory. This configuration file is in standard java.util.Properties format and contains the fully qualified name of the implementation class with the key being the system property defined above. The jaxp.properties file is read only once by the JAXP implementation and it's values are then cached for future use. If the file does not exist when the first attempt is made to read from it, no further attempts are made to...
Created by Dr. Xi on June 20, 2010 14:35:17 Last update: June 20, 2010 14:35:17
This XML signature validator comes from the Apache XML Security project. It validates the signature according to the core validation processing rules . It does not verify that the key used to generate the signature is a trusted key. You can override the KeySelector class to make sure that the signing key is from a trusted store.
import javax.xml.crypto.*; import javax.xml.cry...
Created by Dr. Xi on June 11, 2010 23:11:59 Last update: June 11, 2010 23:14:02
Given a simple XML file like this:
<?xml version="1.0"?> <root id="1"> ...Calling Document.getElementById returns null (surprisingly!):
import java.io.*; import org.w3c.dom.*; impo...In fact the JavaDoc says something along the lines that getElementById returns the Element that has an ID attribute with the given value. An attribute with the name "ID" or "id" is not of type ID unless it is so defined. How is an attribute defined as an ID attribute ? With a DTD or schema. If you are not validating the XML, then the API is useless. So, what to do if you want to find an element for which the attribute named "id" has a given value? Several options were offered in GetElementById Pitfalls . One of them is to...
Created by Fang on April 01, 2010 22:24:58 Last update: April 02, 2010 02:49:38
In this note I'll show you how to create and package a JSP custom tag. The purpose of this tag is to display a random splash image for a home page, among a set of images. We should be able to add or delete candidate splash images from the WAR archive without the need to change the JSP. This is the intended use of the tag:
<%@ taglib uri="http://custom.tag.com/demo" prefix...In the above example you provide a set of images named splash*.png (e.g., splash1.png, spalsh2.png, ...), and the tag will pick a random one to display when the JSP is rendered. Let's get started. I'll use Maven for this purpose. Create the standard Maven directory structure
./pom.xml ./src ./src/main ./src/main/jav...pom.xml
package tagdemo; import java.util.ArrayList......
Created by Dr. Xi on December 12, 2007 20:30:01 Last update: December 12, 2007 20:32:23
This is a script to tail a log file through the web browser. It uses AJAX, apache web server, mod_python, UNIX utilities tail (requires the --lines switch) and wc . The log file may reside on the web server or any other host accessible from the web server through SSH. Although it's written in python, it should be easy to port to other languages such as Perl. Apache httpd.conf :
LoadModule python_module modules/mod_python.so ...Python script:
import time, os from os.path import basename ...