ColdFusion & HttpSessionListener interface

Couple weeks ago some guys from Macromedia stopped by to yack with us about what we thought could be improved and/or added to the next version of CFMX. One of the things that came up a couple times was that it would be nice to have session OnStart and OnEnd functionality as well as application OnStart and OnEnd. Reading this month’s Java Developer’s Journal, it has an article on the HttpSession object (I’d link to it, but they charge for their content… too bad, I bet they’d be getting alot more traffic and readers if they’d provide their content for free), which provides multiple listener objects, HttpSessionListener, HttpSessionBindingListener, HttpSessionAttributeListener, and HttpSessionActivationListener. I don’t have CFMX here at home, but it seems like it would be possible to write a class that implements those either of those interfaces (probably the sessionCreated() and sessionDestroyed methods of the HttpSessionListener object), register that class in the web.xml of WEB-INF for your application like this:


Turns out you could do the same type of thing w/ javax.servlet.ServletContextListener [contextDestroyed() and contextInitialized()] and then register:


in your web.xml and then… hypothetically, you’d have session OnStart, session OnEnd, application OnStart and application OnEnd just like ASP.

I’ll try it out tomorrow, unless you beat me to it.

3 thoughts on “ColdFusion & HttpSessionListener interface”

  1. Aaron (and others reading this blog entry), I just wanted to point out that while perhaps when this entry was written (01/03) one could not read JDJ articles online, you’ll find that indeed you can read the aforementioned article via the link offered above. That’s good news.

  2. I think “perhaps” isn’t the right word. Here’s the direct link to the article as I saw it back in January:

    Notice that if you click the “next” button, you are automatically redirected to a subscription page.

    With that said, it’s great news that the article is now available to everyone. And congratulations on getting rid of the frames. Maybe some of your stuff will actually show up in the search engines now! :)

  3. Hey Aaron, I wasn’t writing that as a sys-con person (I’m not one, though until recently I was tech editor of the CFDJ and had to step down for lack of time). I really was just pointing that out as a fellow reader.

    I guess the confusion (to someone reading the blog entry and these replies) was that I was simply referring to the link you offered to the archives ( I noticed that following the link I was indeed able to read the articles. That’s what I meant by “perhaps” (if back then you were directed to the link showing only the first page). Now, clearly, you get to the full article. That’s all I wanted to point up.

    As for the issue of frames keeping their articles from showing up in search engines, I don’t know if it’s that so much as their using CFMs with a query string for the articleid.

    I can tell you that their sister magazine, LinuxWorld (they acquired it recently) was recently rewritten to use search-engine safe URLs that DO allow it to be indexed by search engines. It’s built on BlueDragon, and can use a method that converts a URL for an [articleid].htm into a URL for that article as a CFM page. (For those interested, I’ll be doing a blog entry on that soon at

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>