Recent Notes
Displaying keyword search results 1 - 10
Created by Fang on December 06, 2011 19:03:25
Last update: December 07, 2011 08:54:11
Our custom tag, as implemented in the previous note , is broken when a template is used.
Create a template file ( home-template.xhtml ):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Stric...
and a test page that uses it ( home.xhtml ):
<?xml version="1.0" encoding="UTF-8"?>
<ui:comp...
Then request the page with URL: http://localhost:8080/facelet-demo/home.jsf?name=Jack .
You'll find that our hello tag works inside ui:repeat but fails to get the value defined by ui:param ! What's the problem? Our hello tag implementation evaluated the EL with the wrong EL context!
This is the corrected implementation:
package com.example;
import java.io.IOExcep...
Created by Dr. Xi on August 11, 2007 15:56:47
Last update: July 19, 2011 08:15:55
Here's a list of common TCP ports. You can find a more complete list here: http://www.gasmi.net/docs/tcp.html . Port Number Service Description 21 FTP File Transfer Protocol 22 SSH Secure Shell 23 Telnet Telnet remote login 25 SMTP Simple Mail Transfer Protocol 70 gopher Gopher 79 finger Finger 80 HTTP Hyper Text Transfer Protocol (WWW) 88 Kerberos Kerberos authentication 94 tivoli Tivoli Object Dispatcher 110 pop3 Post Office Protocol Version 3 123 ntp Network Time Protocol 137 netbios NetBIOS Name Service 138 netbios NetBIOS Datagram 139 netbios NetBIOS Session 143 imap Internet Message Access Protocol 161 snmp Simple Network Management Protocol 162 snmptrap SNMP trap 194 irc Internet Relay Chat Protocol 389 ldap Lightweight Directory Access Protocol 443 https Secure HTTP 445 SMB MS Server Message...
Created by alfa on May 26, 2011 21:16:22
Last update: June 02, 2011 14:39:57
Given a class A :
class A {
public int doWork(String s, int i...
it is OK to call method doWork with both primitive types and the corresponding wrapping object types:
new A().doWork("Hello", 1, false);
new A().doWo...
However, if you find method by parameter types with Java reflection, the types must match exactly, i.e.,
Class<?> c = Class.forName("A");
// This call f...
This is a utility to find methods with compatible parameter types:
import java.lang.reflect.*;
import java.util.*;...
Example usage:
Method m = ReflectionUtil.getCompatibleMethod(c, "...
Created by jinx on April 29, 2011 13:43:13
Last update: April 29, 2011 13:44:34
List of functions testing variable type:
Function Description
is_bool Finds out whether a variable is a boolean
is_double Alias of is_float()
is_float Finds whether the type of a variable is float
is_int Find whether the type of a variable is integer
is_integer Alias of is_int()
is_long Alias of is_int()
is_null Finds whether a variable is NULL
is_numeric Finds whether a variable is a number or a numeric string
is_object Finds whether a variable is an object
is_real Alias of is_float()
is_scalar Finds whether a variable is a scalar
is_string Find whether the type of a variable is string
Test code:
<?php
class A {
}
$a = ar...
Output:
var_dump: int(1)
-------------------------
i...
Created by Dr. Xi on March 30, 2011 13:43:05
Last update: March 30, 2011 13:45:27
Method 1 - use javap with verbose flag:
$ javap HelloWorld -verbose | head
Compiled fro...
Method 2 - use a utility class:
import java.io.*;
import java.nio.ByteBuffer;
...
According to the VM Spec , a Java class file has this structure:
ClassFile {
u4 magic;
...
Created by Dr. Xi on February 01, 2011 14:38:55
Last update: February 01, 2011 14:40:59
Create the stuff you want to manufacture with the factory:
package tc.demo;
public class Junk {
...
Create the factory:
package tc.demo;
import java.util.Enumerati...
Tell Tomcat to use your factory. Create file context.xml and put it under the directory META-INF of your web application:
<Context>
<Resource name="/find/junk/here"
...
Note that beside name , type and factory , you can put any arbitrary attribute in the Resource element.
Access the thing with JNDI:
<%@page language="java" import="javax.naming.*,tc....
The server side log looked like this:
INFO: jndiName: here
INFO: name: scope, value: ...
Also note that, in contrast to Tomcat documentation , resource-ref is not needed in web.xml .
Created by James on September 03, 2010 15:52:12
Last update: January 11, 2011 20:22:40
Use the siblings function to find all siblings of the current jQuery object:
$(this).siblings()
which is equivalent to:
$(this).parent().children().not(this)
Or, use an optional selector to further limit the selection of siblings:
$(this).siblings('li .hilighted')
Test page:
<!DOCTYPE html>
<html>
<head>
<title>jQu...
Created by Dr. Xi on August 30, 2010 15:58:29
Last update: August 30, 2010 15:58:29
Python String does not have functions like substring or substr . Instead, substrings are specified with the slice notation : two indices separated by a colon.
>>> s = 'readme.txt'
>>> s.substring(0, 3)
T...
Created by Fang on August 18, 2010 20:07:46
Last update: August 18, 2010 20:11:36
JSTL uses XPath expressions as a concise notation to specify or select parts of an XML document. JSTL provides EL like expressions to access web application data and comes with the core function library of the XPath specification. Accessing Web Application Data XPath Expression Mapping $foo pageContext.findAttribute("foo") $param:foo request.getParameter("foo") $header:foo request.getHeader("foo") $cookie:foo maps to the cookie's value for name foo $initParam:foo application.getInitParameter("foo") $pageScope:foo pageContext.getAttribute("foo", PageContext.PAGE_SCOPE) $requestScope:foo pageContext.getAttribute("foo", PageContext.REQUEST_SCOPE) $sessionScope:foo pageContext.getAttribute("foo", PageContext.SESSION_SCOPE) $applicationScope:foo pageContext.getAttribute("foo", PageContext.APPLICATION_SCOPE) For example, to find the bar element whose x attribute equals the value of the HTTP request parameter named paramName :
/foo/bar[@x=$param:paramName] Java Type to XPath Type Mappings XPath Type Java Type java.lang.Boolean boolean java.lang.Number number java.lang.String string Object exported by <x:parse> node-set Please note that JSTL, as of version 1.2,...
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...