get - Servlet and path parameters like /xyz/{value}/test, how to map in web.xml? -


does servlet support urls follows:

/xyz/{value}/test 

where value replaced text or number.

how map in web.xml?

it's not supported servlet api have url pattern wildcard * in middle of mapping. allows wildcard * in end of mapping /prefix/* or in start of mapping *.suffix.

with standard allowed url pattern syntax best bet map on /xyz/* , extract path information using httpservletrequest#getpathinfo().

so, given <url-pattern>/xyz/*</url-pattern>, here's basic kickoff example how extract path information, null checks , array index out of bounds checks omitted:

string pathinfo = request.getpathinfo(); // /{value}/test string[] pathparts = pathinfo.split("/"); string part1 = pathparts[1]; // {value} string part2 = pathparts[2]; // test // ... 

if want more finer grained control possible apache httpd's mod_rewrite, @ tuckey's url rewrite filter.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -