Something I learned today about JSTL - you can use {cookie.cookieName.value}* to get the String value of a cookie. Cool stuff, I found it by looking in the JSTL In Action book I bought about a month ago. BTW, if you're going to buy the book, you can get if for $12 cheaper from Amazon.
Here's an example of how I used this new-found syntax in my project.
<c:if test="{cookie.style.value == 'widescreen'}">
body {
background-image: url(/images/bg-wide.gif);
}
</c:if>*
I also implemented the
stylesheet switcher from A List Apart today. Very cool stuff - although I did have to add an extra line in the setActiveStyleSheet
function to create a cookie for title. The following code block is supposed to do this for me, but didn't seem to work on XP with the latest browsers.
window.onunload = function(e) {
var title = getActiveStyleSheet();
createCookie("style", title, 365);
}
Oh well, at least I got it to work and learned some more JSTL in the process!
* I tried using the real syntax with a preceeding $, but that didn't work too well, and Velocity puked with:
[VELOCITY ERROR: parsing weblog entry]
org.apache.velocity.exception.ParseErrorException:
Encountered ".cookieName.value}
Any ideas why? It brings up another question I've been meaning to ask - is it possible to use Velocity syntax that's similar to JSP to get parameters and such in my roller templates?