Re: [CODE4LIB] implementing cool uris in java
Thanks for the replies, everybody! I'm going to take a look at the Url Rewrite Filter pointed out by Peter Kiraly because it looks like the simplest solution at this point. We're currently running under glassfish on port 80, so I'm hoping to keep Apache out of the mix unless we absolutely need it. -emily Emily Lynema wrote: Original Message -- Date:Thu, 3 Jul 2008 00:22:07 -0400 From:Emily Lynema [EMAIL PROTECTED] Subject: implementing cool uris in java I'm looking around for tools to implement cool uris in java. I've been studying the restlet framework tonight, and while it sounds cool, I think it would also require a complete re-write of an application that is currently based on the Servlet API. And, of course, I'm working under a time crunch. Is there anything out there to assist me in working with cool uris besides just using regular expressions when parsing URLs? For example, I'd like to create URLs like: http://catalog.lib.ncsu.edu/record/123456 instead of: http://catalog.lib.ncsu.edu/record?id=1234565 -emily -- Emily Lynema Systems Librarian for Digital Projects Information Technology, NCSU Libraries 919-513-8031 [EMAIL PROTECTED]
Re: [CODE4LIB] implementing cool uris in java
if i understood correctly, you already create urls like http://catalog.lib.ncsu.edu/record?id=1234565. since cool urls are the ones that don't change, you will still have to support these. so i'd think an easy way to support the even cooler http://catalog.lib.ncsu.edu/record/123456 would be to use something like apache's mod_rewrite (http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html) assuming you use apache in front of whatever serves your java code. regards, robert On Thu, Jul 3, 2008 at 6:22 AM, Emily Lynema [EMAIL PROTECTED] wrote: I'm looking around for tools to implement cool uris in java. I've been studying the restlet framework tonight, and while it sounds cool, I think it would also require a complete re-write of an application that is currently based on the Servlet API. And, of course, I'm working under a time crunch. Is there anything out there to assist me in working with cool uris besides just using regular expressions when parsing URLs? For example, I'd like to create URLs like: http://catalog.lib.ncsu.edu/record/123456 instead of: http://catalog.lib.ncsu.edu/record?id=1234565 -emily -- Emily Lynema Systems Librarian for Digital Projects Information Technology, NCSU Libraries 919-513-8031 [EMAIL PROTECTED]
Re: [CODE4LIB] implementing cool uris in java
There are some implementation of mod_rewrite for Java. I personally use UrlRewriteFilter, which is a Java Web Filter for any J2EE compliant web application server (such as Resin, Orion or Tomcat), which allows you to rewrite URLs before they get to your code. All what you should do is adding a jar and editing an xml file. In your example the snippet would be like this: rule from/record/([^\/]+)$/from to/record?id=$1/to /rule You can finde more info in this site: http://tuckey.org/urlrewrite/ Kiraly Peter http://extensiblecatalog.info - Original Message - From: Robert Forkel [EMAIL PROTECTED] To: CODE4LIB@LISTSERV.ND.EDU Sent: Thursday, July 03, 2008 8:42 AM Subject: Re: [CODE4LIB] implementing cool uris in java if i understood correctly, you already create urls like http://catalog.lib.ncsu.edu/record?id=1234565. since cool urls are the ones that don't change, you will still have to support these. so i'd think an easy way to support the even cooler http://catalog.lib.ncsu.edu/record/123456 would be to use something like apache's mod_rewrite (http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html) assuming you use apache in front of whatever serves your java code. regards, robert On Thu, Jul 3, 2008 at 6:22 AM, Emily Lynema [EMAIL PROTECTED] wrote: I'm looking around for tools to implement cool uris in java. I've been studying the restlet framework tonight, and while it sounds cool, I think it would also require a complete re-write of an application that is currently based on the Servlet API. And, of course, I'm working under a time crunch. Is there anything out there to assist me in working with cool uris besides just using regular expressions when parsing URLs? For example, I'd like to create URLs like: http://catalog.lib.ncsu.edu/record/123456 instead of: http://catalog.lib.ncsu.edu/record?id=1234565 -emily -- Emily Lynema Systems Librarian for Digital Projects Information Technology, NCSU Libraries 919-513-8031 [EMAIL PROTECTED]
Re: [CODE4LIB] implementing cool uris in java
On Thu, 3 Jul 2008, Emily Lynema wrote: I'm looking around for tools to implement cool uris in java. I've been studying the restlet framework tonight, and while it sounds cool, I think it would also require a complete re-write of an application that is currently based on the Servlet API. And, of course, I'm working under a time crunch. Is there anything out there to assist me in working with cool uris besides just using regular expressions when parsing URLs? For example, I'd like to create URLs like: http://catalog.lib.ncsu.edu/record/123456 instead of: http://catalog.lib.ncsu.edu/record?id=1234565 I don't know enough about what you're doing, but you can have one program handle both cases .. wherever it's doing it's input validatation, the logic is basically: if ( request.getQueryString ) parse_query_string() else if ( request.getPathInfo ) parse_path_info() else set_defaults() ... And you don't need regular expressions for processing the PATH_INFO -- as it's positional just take the string, and split on '/', and assign them to whatever the corresponding named parameter is. - Joe Hourcle