Recent Notes

Displaying keyword search results 1 - 10
Created by Fang on June 05, 2012 09:12:36    Last update: June 05, 2012 09:13:03
The apache.commons.lang package has a nice utility to escape strings for various language environments. Simply include the dependency in pom.xml : <dependency> <groupId>org.apache.commons</... and use it: // import org.apache.commons.lang3.StringEscapeUti...
Created by Fang on February 21, 2012 20:54:23    Last update: February 21, 2012 20:57:57
Tomcat gzip compression filter can be turned on with " compression=on " in server.xml : <Connector port="8080" protocol="HTTP/1.1" ... The default compressed MIME types are: text/html,text/xml,text/plain . It would be nice to add other types: <Connector port="8080" protocol="HTT...
Created by James on February 02, 2012 15:40:32    Last update: February 02, 2012 15:40:32
It's pretty easy to embed Flash video in HTML with swfobject . This example comes directly from the docs: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Stric... where swfobject.js and expressInstall.swf comes with swfobjects. I provide these files: swf/MySwfFile.swf images/CoverArt.jpg video/MyFlashVideo.flv
Created by James on November 27, 2011 16:02:11    Last update: November 27, 2011 16:02:11
This is an example that uses the XSLTProcessor jQuery plugin for client side XSLT. Unfortunately it didn't work in IE or Chrome. It worked in Firefox but somehow disable-output-escaping="yes" was ignored. <!DOCTYPE html> <html xmlns="http://www.w3.org/...
Created by James on September 07, 2010 22:12:01    Last update: September 07, 2010 22:13:45
I had a need to use Ajax to get a response from the server and conditionally render the results based on a status code. Additionally, I need to update multiple areas on the page from the results of one request. The code presented here uses jQuery and an XML response with CDATA sections to achieve that goal. Server side code (perl cgi): #!C:/perl/bin/perl.exe ## ## redirect ##... The HTML page: <html> <head> <script type="text/javascript...
Created by Fang on March 23, 2010 03:50:11    Last update: August 18, 2010 21:59:52
This is a simple web application with a single servlet and a single JSP page. It is intended to be a test bed for JSTL tags. You may want to store all syntax, rules, and exceptions in your head, but in my opinion nothing beats a simple test program that allows you play with it all you want. So here it is (build with Maven ). Prerequisites: Maven: http://maven.apache.org/ . You don't need any prior knowledge of Maven, but you need to install the binary. JBoss: http://jboss.org/jbossas/downloads/ , or Tomcat: http://tomcat.apache.org/ if you don't run the SQL tests. You need to know how to deploy a web application (shh! Don't tell your boss it's just copying a file to the deployment folder). Steps: The directory...
Created by James on June 30, 2010 19:04:45    Last update: July 03, 2010 21:24:33
Technically, file upload cannot be handled by Ajax, because XMLHttpRequest (XHR) does not handle file inputs. All techniques not using Flash rely on an invisible iframe as the upload form submit target. JavaScript then grabs the response content from the iframe and present it, giving the same illusion as Ajax. webtoolkit AIM The technique by webtoolkit is very simple. It involves 3 simple steps: include the AIM script, implement the start/finish JavaScript functions, and add an onsubmit handler to the normal file upload form. The hooked up form looks like: <head> <script type="text/javascript" src="webt... The AIM script is also quite simple: /** * * AJAX IFRAME METHOD (AIM) * http... The above code only supports HTML responses. In order to support JSON responses, the above...
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 April 22, 2007 21:58:45    Last update: January 19, 2009 20:26:12
Your code will be syntax highlighted when you specify the language of your code with the BBcode code tag: [code=lang] Your code here [/code] where "lang" is the language of your code. For example, the following Perl code #!/usr/bin/perl print "Hello World!\n"; is rendered with: [code=perl] #!/usr/bin/perl print "Hel... The following are supported languages and their corresponding names for BBcode: Apache conf: apacheconf, aconf, apache Bash... The full list is available from http://pygments.org/ , which is our backend engine for syntax highlight rendering.
Created by Dr. Xi on December 12, 2007 20:30:01    Last update: December 12, 2007 20:32:23
This is a script to tail a log file through the web browser. It uses AJAX, apache web server, mod_python, UNIX utilities tail (requires the --lines switch) and wc . The log file may reside on the web server or any other host accessible from the web server through SSH. Although it's written in python, it should be easy to port to other languages such as Perl. Apache httpd.conf : LoadModule python_module modules/mod_python.so ... Python script: import time, os from os.path import basename ...
Previous  1 2 Next