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
2 Peter P // May 6, 2010 at 9:58 PM
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
// 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
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
Leave a Comment