Recent Notes

Displaying keyword search results 81 - 90
Created by James on July 06, 2010 19:35:00    Last update: July 06, 2010 19:35:00
Java has built-in functions to get the basename and dirname for a given file path, but the function names are not so self-apparent. import java.io.File; public class JavaFileD... Results: C:\tmp>java JavaFileDirNameBaseName Dirname: .....
Created by James on June 30, 2010 20:14:28    Last update: July 03, 2010 18:41:12
The HTML page <!DOCTYPE html> <html> <head> <title>jQu... Client Side Code // called before upload submit function sta... Server Side Code Using Apache Commons FileUpload as example. Upload code (responds to fileUpload.do ): final HttpSession session = httpServletRequest... Progress code (responds to uploadProgress.do ): HttpSession session = httpServletRequest.getSe...
Created by magnum on June 23, 2010 22:24:01    Last update: June 23, 2010 22:24:01
Required: Apache web server mod_proxy_html proxy_html.conf: # Load mod_proxy_html required SOs LoadFile /us... httod.conf # load proxy_html conf Include conf/extra/proxy...
Created by magnum on June 23, 2010 19:02:32    Last update: June 23, 2010 19:05:08
Get the public keys. The Apache HTTPD developer keys are available from: http://www.apache.org/dist/httpd/KEYS . Save the key file as KEYS . Import the keys into your keyring. The GPG ring is stored at $HOME/.gnupg/pubring.gpg . gpg --import KEYS Verify the signature. Using mod_proxy_html as example: C:\Downloads>gpg mod_proxy_html.zip.asc gpg: Si...
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 03, 2010 22:43:43    Last update: June 20, 2010 14:13:05
Using the Sun BASE64Encoder : import java.io.*; import sun.misc.BASE64Encoder... However, the Sun encoder is awfully slow. The Apache encoder is a lot faster. Here's the code with Apache encoder: import java.io.*; import org.apache.commons.cod... Performance comparisons between Apache and Sun: C:\>bash bash-3.2$ time java EncodeFileWithBase...
Created by Dr. Xi on June 19, 2010 04:34:01    Last update: June 19, 2010 04:39:13
Java SE 6 contains built-in utilities to generate XML signatures. This is an example that generates XML signatures using a Java keystore. It has options to generate signature for the whole document, for an element with a specific ID, or for elements matched by an XPATH expression. The XML document used to test is taken from Getting Started with XML Security : <?xml version="1.0"?> <PatientRecord> ... This is the Java code: import java.io.FileInputStream; import java.io.... However, it looks like the XPATH transform is not working. The digest generated with XPATH filter is exactly the same as that without it (i.e., the whole document)! Another reference: Programming With the Java XML Digital Signature API
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 <project xmlns="http://maven.apache.org/POM/4.0.0"... SplashTag.java package tagdemo; import java.util.ArrayList......
Created by Dr. Xi on January 07, 2010 23:40:28    Last update: February 09, 2010 03:24:35
This is a utility to generate SQL insert statements for Oracle for one table, or a set of tables. It doesn't cover all possibilities but should be good enough for most cases. import java.io.*; import java.sql.*; import ... To generate insert statements for multiple tables, simply put the table names in a file, one per line, and use the -f switch.
Previous  2 3 4 5 6 7 8 9 10 11 Next