Notes by Dr. Xi

Displaying keyword search results 1 - 10
Created by Dr. Xi on April 19, 2012 10:10:08    Last update: April 19, 2012 10:11:06
The default servlet for Tomcat is declared in $CATALINA_HOME/conf/web.xml : <servlet> <servlet-name>default</servle... Therefore, static content is rendered by the default configuration unless you override it with your own definitions. If you want to allow directory listing, just change the listing parameter to true : <init-param> <param-name>listings</para... Change the welcome-file-list to display a default page in lieu of a directory listing: <welcome-file-list> <welcome-file>home.xhtml</... Welcome pages are defined at the Web application level.
Created by Dr. Xi on March 13, 2012 08:46:57    Last update: March 13, 2012 08:46:57
This trick sets HTML base to the root context path of the current webapp: The short version: <!DOCTYPE html> <%@ taglib uri="http://java.sun... The long version: <!DOCTYPE html> <%@ taglib uri="http://java.sun...
Created by Dr. Xi on March 08, 2012 09:16:02    Last update: March 08, 2012 09:16:02
In my JSP there's a link like this: <a href="/path/${part1}/${part2}">the link</a> where part1 and part2 may contain characters that need to be URL encoded (such as '#'). JSP JSTL does not provide such facility out of the box. But there's a hack using <c:url> , or you can use <spring:url> : JSTL hack: <c:url value="/path" var="theUrl"> <c:param... Using Spring url tag: <spring:url value="/path/{part1}/{part2}" var="enc...
Created by Dr. Xi on February 13, 2012 20:59:35    Last update: February 13, 2012 20:59:54
The insertAttribute tag allows you to have a body as well as specify a default value, but both values are scriptless , i.e., scriptlet is not allowed in body: <tiles:insertAttribute name="javascript"> <scri... and defaultValue is output literally: <tiles:insertAttribute name="javascript" de... And, <put-attribute> in tiles definition does not replace the body of <tiles:insertAttribute> , it appends to the body!
Created by Dr. Xi on February 13, 2012 20:48:56    Last update: February 13, 2012 20:48:56
When you insert an attribute in JSP: <%@ taglib uri="http://tiles.apache.org/tags-tiles... you must define the attribute in tiles definitions: <definition name="/home" template="/WEB-INF/templa... Otherwise you'll get runtime exception. The ignore attribute, which defaults to false , will suppress the runtime exception when the attribute is not defined in tiles definition: <%@ taglib uri="http://tiles.apache.org/tags-tiles...
Created by Dr. Xi on February 01, 2012 12:55:28    Last update: February 01, 2012 12:55:28
You can define environment variables in the Tomcat context.xml file like this: <?xml version="1.0" encoding="UTF-8"?> <Context... which is equivalent to the following in web.xml : <env-entry> <env-entry-name>varName</env-entr... In Java code, the variable can be looked up like this: // import javax.naming.Context; // import javax...
Created by Dr. Xi on October 01, 2007 03:26:46    Last update: August 25, 2011 08:57:40
Use the sub function in the re module to do global replacement: import re re.sub(pattern, replacement, inpu...
Created by Dr. Xi on April 20, 2011 21:44:15    Last update: May 02, 2011 20:56:58
The String.format() method provides versatile formatting capabilities. This tutorial tries to present these capabilities in a accessible manner. The format string A format string can contain zero, one, or more format specifiers . The general form of a format specifier is: %[argument_index$] [flags] [width] [.precision]co... where things in square brackets are optional, and conversion is a character indicating the conversion to be applied to the corresponding variable value. The only required characters in the format specifier is the percent sign % and the conversion character. A simple example: public static void simpleFormat() { System.out... The Argument index The argument index is specified by a number, terminated by the dollar sign $ . The same argument may be repeated multiple times in a format string. Unindexed...
Created by Dr. Xi on April 26, 2011 20:12:01    Last update: April 28, 2011 15:28:12
An XML schema is a definition of XML files, in XML. It plays the same role as old-time DTDs. Overall, an XML schema file looks like this: <schema attributeFormDefault = (qualified | u... The attribute meanings: targetNamespace : The name space targeted by the current schema definition. It can be any URI. id and version : For user convenience, the W3C spec defines no semantics for them. xml:lang : Natural language identifier defined by RFC 3306 . attributeFormDefault and elementFormDefault : Set default values for the form attribute for attribute and element declarations. blockDefault and finalDefault : Set default values for the block and final attributes for attribute and element declarations. The W3C defined some built-in datatypes . Examples of primitive datatypes are: string ,...
Created by Dr. Xi on April 26, 2011 21:25:55    Last update: April 27, 2011 11:08:57
The following code validates a web.xml file against the web-app 2.5 schema: // Java XML validation with schema import java.... web.xml used for testing: <?xml version="1.0" encoding="UTF-8"?> <web-ap... According to Java API doc , validation can also be done while parsing by calling setSchema on the parsing factory. However, validation doesn't work for the SAXParserFactory! // Java XML validation with schema import java....
Previous  1 2 3 4 5 6 7 8 9 10 Next