http://seancorfield.github.io for newer blog posts." />

An Architect's View

CFML, Clojure, Software Design, Frameworks and more...

An Architect's View

Railo for Dummies Part V

June 30, 2009 · 5 Comments

I wanted to follow up on Part IV Appendix about SES URLs with Tomcat. Tony Garcia mentioned it there in a comment and since then Jamie Krug mentioned it in a comment on the Railo blog: Tomcat can do SES URLs, albeit with some limitations.If you set the <url-pattern> to /index.cfm/* then Tomcat will handle URLs of the form /index.cfm/event/product/id/1234 correctly. If you use multiple entry points with SES URLs, you will need a servlet mapping for each URL. For example, on this site I have /index.cfm for my personal site and /blog/index.cfm for this blog. By adding URL patterns for both /index.cfm/* and /blog/index.cfm/* I can use SES URLs natively with Tomcat on both of those applications. So, not a new tip but I felt it was worth surfacing it in its own blog post. Thank you Tony and Jamie!

Tags: coldfusion · railo

5 responses so far ↓

  • 1 Hatem Jaber // Mar 4, 2010 at 7:09 AM

    I know this is an older post, but I wanted to point out (in case it hasn't already been done on other posts) that there is a urlrewrite filter made for java by Paul Tuckey. I posted this here as I was skimming through the blog since I will put it to the test and see if it's similar to Apache. If it is, that will be 1 less app to install leaving only Tomcat and Railo for serving the pages!
  • 2 Peter P // May 6, 2010 at 9:58 PM

    I have my URL as:
    site-root/blog/index.cfm/2004/4/1/
    and had /blog/index.cfm/* in servlet-mapping. Everything seems to work except cgi.path_info still includes "/blog" in it. How can I make it to "/2004/4/1/" without converting to URL variable?
  • 3 Sean Corfield // May 6, 2010 at 10:33 PM

    @Peter, are you using IIS or Apache? They behave differently when populating PATH_INFO. For IIS, you have to strip SCRIPT_NAME from the front of PATH_INFO. Look at this code (this is from FW/1):

          // SES URLs by popular request :)
          if ( len( pathInfo ) gt len( CGI.SCRIPT_NAME ) and left( pathInfo, len( CGI.SCRIPT_NAME ) ) is CGI.SCRIPT_NAME ) {
             // canonicalize for IIS:
             pathInfo = right( pathInfo, len( pathInfo ) - len( CGI.SCRIPT_NAME ) );
          } else if ( len( pathInfo ) gt 0 and pathInfo is left( CGI.SCRIPT_NAME, len( pathInfo ) ) ) {
             // pathInfo is bogus so ignore it:
             pathInfo = '';
          }
          pathInfo = listToArray( pathInfo, '/' );
          for ( sesIx = 1; sesIx lte arrayLen( pathInfo ); sesIx = sesIx + 1 ) {
             if ( sesIx eq 1 ) {
                request.context[variables.framework.action] = pathInfo[sesIx];
             } else if ( sesIx eq 2 ) {
                request.context[variables.framework.action] = pathInfo[sesIx-1] & '.' & pathInfo[sesIx];
             } else if ( sesIx mod 2 eq 1 ) {
                request.context[ pathInfo[sesIx] ] = '';
             } else {
                request.context[ pathInfo[sesIx-1] ] = pathInfo[sesIx];
             }
          }
  • 4 Peter P // May 6, 2010 at 11:14 PM

    Hi Sean,
    I use Railo on Apache Tomcat.
    When opening the url (site-root/blog/index.cfm/2004/4/1/)
    My CGI.PATH INFO returns "/blog/2004/4/1/" while my CGI.SCRIPT_NAME returns "/blog/index.cfm"

    my Tomcat web.xml also has both:
    <servlet-mapping>
       <servlet-name>CFMLServlet</servlet-name>
       <url-pattern>/blog/index.cfm/*</url-pattern>
       </servlet-mapping>
    <servlet-mapping>
       <servlet-name>CFMLServlet</servlet-name>
       <url-pattern>/index.cfm/*</url-pattern>
       </servlet-mapping>

    However, as soon as I remove the "/index.cfm/*", the page failed and Apache returns 404 msg. Meaning that somehow, the other mapping "/blog/index.cfm/*" never actually works
  • 5 Sean Corfield // May 7, 2010 at 9:30 PM

    @Peter, no idea. It looks fine to me (and indeed works fine for me). Try asking on the Railo mailing list and see if anyone else has a suggestion.

Leave a Comment

Leave this field empty