Recent Notes

Displaying keyword search results 1 - 7
Created by James on February 02, 2012 16:00:15    Last update: February 02, 2012 16:00:15
Video for Everybody seems to be a generic way to embed video in a web page, even without flash. This code snippet comes from that site. <!-- first try HTML5 playback: if serving as XML, ...
Created by Fang on November 10, 2011 09:26:12    Last update: November 10, 2011 09:26:12
Syntax highlighted XML schema for JSF 2.0 Application Configuration Resource File ( faces-config.xml ). Almost 3000 lines! <?xml version="1.0" encoding="UTF-8"?> <xsd:sch...
Created by James on May 24, 2009 20:14:25    Last update: January 11, 2011 20:07:38
In the following HTML code, I attached an inline handler to the text field input and added two event handlers with addEventListener / attachEvent . Both IE and Firefox called the inline handler first. But the order in which the added event handlers were called are different between IE and Firefox (IE calls attached_click2 first). Further, if I add the same event handler multiple times, IE calls the handler the same number of times. But Firefox only calls the same handler once, no matter how many times it was added. <html> <body> <form> Input: <input type="... You can attach an event handler to an HTML element either inline , with JavaScript , or by calling addEventListener (DOM level 2), or attachEvent (IE specific). When you...
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 James on March 16, 2010 16:55:51    Last update: March 16, 2010 19:29:28
I had this seemingly innocent code that did not work: <html> <body> <script language="JavaScript"... I fired up the Chrome JavaScript console and it told me that: Uncaught TypeError: object is not a function . When the name sameAsInputName appeared in the inline event handler, the browser thinks that it refers to the input field(s), not the JavaScript function! It works as expected if you attach the event handler later: <html> <body> <script language="JavaScript"...
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 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....