Recent Notes
Displaying keyword search results 1 - 11
Created by Fang on October 28, 2011 13:49:40
Last update: October 30, 2011 19:23:25
This is a simple example to demonstrate the templating power of JSF facelets. If you've used struts tiles before, you'll recognize the simplicity of templating with facelets. I've stripped out everything else except the pages themselves, just to put our focus on facelets. This is a Maven based project, and you need Tomcat (or any servlet container) to run the resulting webapp. To begin with this is the list of files:
./pom.xml ./src/main/webapp/home.xhtml ./src... I left faces-config.xml in there for completeness sake, it may not be needed. The Maven POM ( pom.xml ): <?xml version="1.0" encoding="UTF-8"?> <project... Web app configuration ( WEB-INF/web.xml ): <?xml version="1.0" encoding="UTF-8"?> <web-app... Empty WEB-INF/faces-config.xml : <?xml version="1.0" encoding="UTF-8"?> <!-- Thi... index.jsp is simply a redirect to home.jsf : <% response.sendRedirect("home.jsf"); %>...
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.keystore
Build again:
$ ant debug
The new key is valid for 30 years (keystore password is 'android'):
$ keytool -list -v -keystore ~/.android/debug.keys...
Created by freyo on May 20, 2011 09:25:20
Last update: May 23, 2011 12:11:42
The javax.xml.crypto and javax.xml.crypto.dsig packages are not available in Android (as of version 2.3). Therefore, standard Java API does not work. But you can use the Apache Santuario library to do that. Here are the steps:
Download the xml security source distribution (curently version 1.4.4).
Build with ant.
Create your own library jar (only the apache classes, no javax):
jar -cf xmlsec-1.4.4.jar -C build/classes org
Copy xmlsec-1.4.4.jar to the libs directory of your Android project.
Here's the Java code:
import java.io.*;
import javax.xml.parsers.*;
...
Created by Dr. Xi on April 27, 2011 11:57:36
Last update: April 27, 2011 11:58:35
This is a sample struts-config.xml file for Struts 1.x .
<?xml version="1.0" encoding="UTF-8"?>
<!DO...
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 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 January 08, 2010 03:53:37
Last update: January 08, 2010 03:54:56
This is an Ant custom task to merge Properties files I lifted from http://marc.info/?l=ant-user&m=106442688632164&w=2 , with some minor bug fixes.
Example usage:
<taskdef name="mergeProperty" classname="ant.task....
Implementation:
package ant.task.addon;
import java.io.Buff...
Created by Dr. Xi on July 28, 2009 19:00:55
Last update: July 28, 2009 19:03:57
When you install Apache with mod_ssl, an executable file openssl (or openssl.exe for Windows) is installed in /usr/local/ssl/bin (or %APACHE_HOME%/bin ). This utility is used to generate private key and certificate request:
Generate private key:
openssl genrsa -out server.key 1024
# or wi...
Generate certificate request:
openssl req -new -key server.key -out server.csr
...
Self-Sign Certificate:
openssl x509 -req -days 3650 -in server.csr -signk...
Apache configuration:
Listen 443
<VirtualHost *:443>
ServerNam...
In some configurations
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unc...
is used to work around MSIE bugs. See http://httpd.apache.org/docs/2.2/ssl/ssl_faq.html#msie for details.
Created by Dr. Xi on October 23, 2008 03:54:04
Last update: October 23, 2008 03:57:44
Add validator plugin in struts-config.xml
<struts-config>
.
.
.
...
Set validate="true" on action form
<struts-config>
<!-- ========== Form Bean De...
Add validation rules in validation.xml
<?xml version='1.0' encoding='windows-1252'?>
<...
If you override validate , make sure super.validate is called.
package com.example;
import javax.servlet.h...
Read the documentation:
http://struts.apache.org/1.2.4/userGuide/dev_validator.html
Created by Dr. Xi on October 15, 2008 21:49:22
Last update: October 15, 2008 21:49:22
Follow these steps to prevent form double submission in struts: In the action class leading to the display of the form, call saveToken(request) In the action class handling the form submission, check the validity of the token by calling isTokenValid(request) . If token is valid, reset the token by calling resetToken(request) , then continue processing the form submission. Otherwise, skip form processing since it's double submission. How doe it work? saveToken generates a unique token and saves it in the session under the key org.apache.struts.action.TOKEN . When the form is rendered, the struts html:form tag generates a hidden field named org.apache.struts.action.TOKEN . Upon form submission, isTokenValid compares the token stored in the session with that submitted from the form. If they are equal, return true....