Hello Peter,

actually the parser does not take into account special characters such as
":".
You can update your code like this :
               Router router = new Router();
               Handler getXml = new GetXml();
               router.attach("/getXml/{PID}:{VALUE}", getXml);
               Handler trace = new Trace();
               router.attach("/trace", trace);
You will get 2 attributes : "PID" and "VALUE".

I hope it will helps
Thierry Boileau

PS :
This behaviour will change in a very short time (end of the week) because
Jérôme is updating this part of the project.
As mentionned earlier in this discussion, Jérôme is rethinking the URI
routing that will rely on a URI template standardization process.


Jerome's mail
The recent initiative on URI templates standardization [1], the potential
confusion between Java Regex and the support for URI templates added in beta
20, a close reading of the URI RFC [2] and the recent comments from Chris
Grindstaff and Yuri de Wit led me to fully rething the URI routing in the
framework.

Here are some conclusions that I have reached:
- resources are identified by a URI, not just the hierarchical path of a
URI
- valid URIs such as URNs should be easily routable, like HTTP URLs
- the query part of URIs should be easily routable, like the path part
- the fragment part of URIs shouldn't be routable, as defined by URI RFC,
section 6.1 [3]
- several query part formats are possible and should be supported
- the common one ("p1=v1&p1=v2&p2=v3") should have additional support (via
Reference.getQueryAsForm() method for example)

I'm planning to refactor this part of the framework for 1.0 RC1. I will add
a Route class (subclass of Scorer containing a list of variable description)
and a Variable class describing the type of template variable (regex to
match, etc).

[1]
http://bitworking.org/projects/URI-Templates/draft-gregorio-uritemplate-00.h
tml
[2] http://www.gbiv.com/protocols/uri/rfc/rfc3986.html
[3] http://www.gbiv.com/protocols/uri/rfc/rfc3986.html#equivalence
[4] https://wadl.dev.java.net/wadl20061109.pdf




On 12/12/06, Peter Murray <[EMAIL PROTECTED]> wrote:

Something seems to be swallowing colons from the relative part of the URL
when using the hierarchical URIs function.  My code looks like this:

                Router router = new Router();
                Handler getXml = new GetXml();
                router.attach("/getXml/{PID}", getXml);
                Handler trace = new Trace();
                router.attach("/trace", trace);

                // Then attach it to the local host
                container.getDefaultHost().attach("/base", router);

Trace() is a copy of the example from the tutorial.  (It, by the way,
is behaving fine.)  The beginning of getXml looks like this:

        public void handle(Request request, Response response) {
                String pid=(String) request.getAttributes().get("PID");

One URL showing the problem is "http://localhost:8182/base/getXml/test:2";.
When I put a breakpoint in the debugger right at the getAttributes() line,
what I get back as the value of 'pid' is simply "test".  I've tried
encoding the colon on the URL with "\:" and "\\:" and "%3a" but the
result is always the same -- the colon and everything after it is gone.
Interestingly, the access log show it to be there:

  INFO: 2006-12-12 15:54:15 GET /base/getXml/test:2 - ...

Any helpful advice from anyone?  Thanks in advance,


Peter

Reply via email to