Recent Notes

Displaying keyword search results 1 - 8
Created by magnum on October 08, 2014 11:29:18    Last update: October 08, 2014 11:29:18
Example C code to set the "Type Of Service" (TOS) field, lifted from http://stackoverflow.com/questions/11429403/how-to-set-message-priority-using-tos . #include <string.h> #include <netdb.h> i...
Created by alfa on July 01, 2011 13:16:12    Last update: July 01, 2011 13:16:12
This is a simple doclet that prints all public methods and their parameter names and types. Code import com.sun.javadoc.*; public class List... Compile javac -cp $JAVA_HOME/lib/tools.jar:. ListMethodsDo... Use javadoc -doclet ListMethodsDoclet -sourcepath /pat...
Created by alfa on May 27, 2011 11:19:29    Last update: May 31, 2011 07:56:26
This is a utility to convert a string value to one of the primitive type values. It is useful in Java reflection code where the value comes in as a string (e.g., from XML parsing), and the type of the value cannot be decided until runtime. import java.util.*; import java.lang.reflect.*;... Note: This method can be extended to convert string to more complex types by writing a converter for the destination type. For example, to convert string to date: public class DateConverter { public static ... Usage: Date d = (Date) ConvertUtil.convert("10/12/2010", ...
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 Fang on August 10, 2010 21:37:36    Last update: October 25, 2010 20:18:47
The tags <fmt:formatNumber> Format a numeric value as number , currency or percentage - controlled by the type attribute (defaults to number if type is missing). Syntax: <fmt:formatNumber value="numericValue" [type="... Attributes: Name Dynamic? Type Description value true String or Number Numeric value to be formatted. type true String Specifies whether the value is to be formatted as number, currency, or percentage. pattern true String Custom formatting pattern, must follow the pattern syntax specified by the class java.text.DecimalFormat . currencyCode true String ISO 4217 currency code. Applied only when formatting currencies (i.e. if type is equal to "currency"); ignored otherwise. currencySymbol true String Currency symbol. Applied only when formatting currencies (i.e. if type is equal to "currency"); ignored otherwise. It is used only when currencyCode is...
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 Fang on April 03, 2010 20:21:15    Last update: April 04, 2010 03:30:22
The tags <c:out> The <c:out> tag evaluates an expression and outputs the result on the page. The syntax is: <c:out value="value" [escapeXml="{true|false}"] ... where escapeXml defaults to true and default defaults to empty string "". <c:out value="${expr}" escapeXml="false"/> is equivalent to ${expr} . If a variable is set in multiple scopes, the lower scope wins. In the following example code, attribute1 is set in request, session, and application scopes; attribute2 is set in session and application scopes; attribute3 is set in the application scope. The results are: <c:out value="${attribute1}"/> : Attribute1 request scope <c:out value="${attribute2}"/> : Attribute2 session scope <c:out value="${attribute3}"/> : Attribute3 application scope To access values in higher scopes, you have to specify the scope explicitly, like this: <c:out value="${sessionScope.attribute1}"/> : Attribute1 session...
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......