use of getPathParameters

54 views
Skip to first unread message

Kasper Janssens

unread,
Jun 5, 2022, 2:15:15 PM6/5/22
to Undertow Dev
Hi,

I am missing the point of the getPathParameters() call on HttpServerExchange.
I define a route like this :
```
RoutingHandler routingHandler = new RoutingHandler();
routingHandler.get("/hello/{email}/{something}", this::myHandle);
```
My expectations is that when, inside myHandle, when I do a client call, that this code
```
public void myHandle(HttpServerExchange exchange) {
    System.out.println(exchange.getPathParameters());
}
```
will print those path parameters, but it seems to return an empty deque. However, the getQueryParameters reports those variables correctly (because the RoutingHandler's default ctor sets a flag that adds the path params to the query params list).
I get that it is kinda convenient of adding those path params also to the query params list, it's transparant then for the handler in a way, but why are those variables not present in the path parameters list? It feels like I am missing something here, and the documentation is not very clear on this topic it seems (Or I have missed it).

Can somebody tell me what I am missing here? Are my expectations of the path params wrong? When would there be some data inside the path params list then? It's not that I cannot work with the getQueryParameters function, it just bugs me that I don't get wy getPathParameters is empty in this case.

This is on undertow 2.2.17-Final, java 17 and ubuntu 20.04

Kasper

Stuart Douglas

unread,
Jun 12, 2022, 5:55:31 PM6/12/22
to Kasper Janssens, Undertow Dev
Path parameters are URI path parameters, they are generally delimited by a semicolon, and have mostly been used historically for JSESSIONID.

For the routing handler parameters they are usually put on the exchange as an attachment under io.undertow.util.PathTemplateMatch#ATTACHMENT_KEY.

Stuart

--
You received this message because you are subscribed to the Google Groups "Undertow Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to undertow-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/undertow-dev/cebc130f-cbcc-4503-969d-25c95d2d3ff0n%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kasper Janssens

unread,
Jun 14, 2022, 7:03:43 AM6/14/22
to Stuart Douglas, Undertow Dev
That's indeed how I understood it from reading the code but the use of semicolon indicates query parameters I thought? It is mentioned as an alternative to the ampersand, iiuc. But maybe I'm mistaken. Anyway thanks for the answer, was a bit confusing for me, different expectations from path vs query params.

Stuart Douglas

unread,
Jun 14, 2022, 8:25:03 AM6/14/22
to Kasper Janssens, Undertow Dev
Query parameters are delimited by a question mark. Path parameters are rarely used, and are basically just a pain as technically they can be part of any path segment.

Stuart

Kasper Janssens

unread,
Jun 14, 2022, 8:44:32 AM6/14/22
to Stuart Douglas, Undertow Dev
Hmm, okay maybe the confusion is then that I read stuff like /base/{word}/{anotherword}/ as having two path parameters (word and anotherword), but path parameter is likely an overloaded term then, or plain wrong in this case.

Op di 14 jun. 2022 om 14:25 schreef Stuart Douglas <sdou...@redhat.com>:
Reply all
Reply to author
Forward
0 new messages