6

How would one route the following path in Jetty ?

/users/user_id/transactions/transaction_id

I tried it this way:

/users/*/transactions/*

But I'm getting an error stating below :

java.lang.IllegalArgumentException: Servlet Spec 12.2 violation: glob '*' can only exist at end of prefix based matches: bad spec "/users/*/transactions"

What is the solution to this ?

1 Answer 1

6

In web.xml, if you give an URL pattern like this down below :

    <servlet-mapping>
       <servlet-name>servletName</servlet-name>
       <url-pattern>/users/*</url-pattern>
    </servlet-mapping>

So, the URL pattern /users/* denotes that all those requests will be accepted that starts with /users/ and ends with anything. For example : /users/get/all

But you can't give an URL pattern like /users/*/anything/*/.. which is not allowed.

A screenshot of 12.2 Specification of Mapping from Oracle - Java™ Servlet Specification Book - Version 4.0 :

enter image description here

Sign up to request clarification or add additional context in comments.

4 Comments

Too bad! I had no idea it would be impossible.
I have added the pdf. Please refer to it.
If you don't mind working with non-standard Jetty only features, there is a way to use URI Templates or Regex to map servlets (but not via the WEB-INF/web.xml). You interested?
@JoakimErdfelt it would be great if you can share an link with the description of jetty regex map.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.