« February 2006 | Main | April 2006 »
March 30, 2006
Handling cookies in JavaScript
Posted by pj at 10:02 AM
March 29, 2006
Windows XP on a MacBook Pro how-to
OnMac.net: Windows XP on Intel Macs
Posted by pj at 09:11 PM
March 13, 2006
Setting firewall rules on Fedora Core 4
Use the following utility:
system-config-securitylevel
Posted by pj at 12:25 PM
March 09, 2006
Issues getting the Tomcat bundled with Magnolia to start
I kept getting an error message saying that the BASEDIR
environment variable was incorrectly set. This went away once I'd made lots of stuff executable in the Tomcat bin directory.
This was a weird file permissions thang!
Posted by pj at 11:24 AM
JavaScript code for base64 encoding and decoding mailto URLs
//First things first, set up our array that we are going to use.
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + //all caps
"abcdefghijklmnopqrstuvwxyz" + //all lowercase
"0123456789+/="; // all numbers plus +/=
//Heres the encode function
function base64_encode(inp)
{
var out = ""; //This is the output
var chr1, chr2, chr3 = ""; //These are the 3 bytes to be encoded
var enc1, enc2, enc3, enc4 = ""; //These are the 4 encoded bytes
var i = 0; //Position counter
do { //Set up the loop here
chr1 = inp.charCodeAt(i++); //Grab the first byte
chr2 = inp.charCodeAt(i++); //Grab the second byte
chr3 = inp.charCodeAt(i++); //Grab the third byte
//Here is the actual base64 encode part.
//There really is only one way to do it.
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
//Lets spit out the 4 encoded bytes
out = out + keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) +
keyStr.charAt(enc4);
// OK, now clean out the variables used.
chr1 = chr2 = chr3 = "";
enc1 = enc2 = enc3 = enc4 = "";
} while (i < inp.length); //And finish off the loop
//Now return the encoded values.
return out;
}
//Heres the decode function
function base64_decode(inp)
{
var out = ""; //This is the output
var chr1, chr2, chr3 = ""; //These are the 3 decoded bytes
var enc1, enc2, enc3, enc4 = ""; //These are the 4 bytes to be decoded
var i = 0; //Position counter
// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
var base64test = /[^A-Za-z0-9\+\/\=]/g;
if (base64test.exec(inp)) { //Do some error checking
alert("There were invalid base64 characters in the input text.\n" +
"Valid base64 characters are A-Z, a-z, 0-9, ?+?, ?/?, and ?=?\n" +
"Expect errors in decoding.");
}
inp = inp.replace(/[^A-Za-z0-9\+\/\=]/g, "");
do { //Here’s the decode loop.
//Grab 4 bytes of encoded content.
enc1 = keyStr.indexOf(inp.charAt(i++));
enc2 = keyStr.indexOf(inp.charAt(i++));
enc3 = keyStr.indexOf(inp.charAt(i++));
enc4 = keyStr.indexOf(inp.charAt(i++));
//Heres the decode part. There’s really only one way to do it.
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
//Start to output decoded content
out = out + String.fromCharCode(chr1);
if (enc3 != 64) {
out = out + String.fromCharCode(chr2);
}
if (enc4 != 64) {
out = out + String.fromCharCode(chr3);
}
//now clean out the variables used
chr1 = chr2 = chr3 = "";
enc1 = enc2 = enc3 = enc4 = "";
} while (i < inp.length); //finish off the loop
//Now return the decoded values.
return out;
}
function encode(text){
document.write(base64_encode(text));
}
function decode(text){
document.write(base64_decode(text));
}
function decode_mailto(text){
dato = new Date();
email = base64_decode(text);
email2 = email.replace('@',"@");
email3 = email2.replace('.',".");
//alert(email3);
document.write('' + email3 + '');
}
function decode_link_mailto(text){
dato = new Date();
email = base64_decode(text);
email2 = email.replace('@',"@");
email3 = email2.replace('.',".");
//alert(email3);
document.write('<a href="mailto:' + email +'">' + email3 + '</a>');
}
Posted by pj at 10:22 AM
March 07, 2006
Magnolia docs
Magnolia CMS developer documentation
Posted by pj at 07:59 PM
Open Source Java CMS
Magnolia Content Management Suite
Posted by pj at 04:15 PM
Getting JSTL EL working on Tomcat 5.0.x
I copied my content into the correct folder but some of my EL expressions weren't working.
This is because I needed namespace declarations in the <web-app/>
tag in the web.xml
file:
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
Posted by pj at 01:55 PM