what i've learned

keeping track of what i'm learning

csc309 tomcat & js cookies

# Using Tomcat
# the following are commands to run on cdf

# download Tomcat
wget http://apache.sunsite.ualberta.ca/tomcat/tomcat-6/v6.0.18/bin/apache-tomcat-6.0.18.tar.gz
tar xzf apache-tomcat-6.0.18.tar.gz

# configure Tomcat
cd apache-tomcat-6.0.18
pico conf/server.xml
# change 8080’s to your assigned port number

# run Tomcat
bash
export JAVA_HOME=/local/packages/jdk1.6.0_07/
bin/startup.sh
# view http://localhost:PORT_NUMBER/ in your browser on cdf to test that it works


# get a sample application
cd webapps
wget http://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/sample.war
# view http://localhost:PORT_NUMBER/sample in your browser on cdf to test that the sample app works
cd ../


# stop Tomcat
bin/shutdown.sh



// Cookies in Javascript

// The manual (tedious) way to set a cookie
document.cookie = ‘ppkcookie1=testcookie; expires=Thu, 2 Aug 2010 20:47:11 UTC; path=/’;

// The easy way
// from http://www.quirksmode.org/js/cookies.html

// if days == 0, cookie expires when the user closes their browser
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = “; expires=”+date.toGMTString();
} else var expires = “”;
document.cookie = name+”=”+value+expires+”; path=/”;
}

function readCookie(name) {
var nameEQ = name + “=”;
var ca = document.cookie.split(‘;’);
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==’ ‘) c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}

function eraseCookie(name) {
createCookie(name,”“,-1);
}

Running Apache

see my last tutorial post for instructions on running Apache

Comments (View)
blog comments powered by Disqus