For dynamic url's such as use case you have. you should be have all the dynamic pages inside a directory, lets say dynamicpages
folder. And you should be mapping a directory url pattern like below :
<filter-mapping>
<filter-name>foo.bar.MyFilter</filter-name>
<url-pattern>/dynmaicpages/*</url-pattern>
</filter-mapping>
<servlet-mapping>
<servlet-name>foo.bar.MyServlet</servlet-name>
<url-pattern>/dynmaicpages/*</url-pattern>
</servlet-mapping>
You can get the Unique id using the following methods:
HttpServletRequest.getPathInfo()
If you have servlet mapping like above, this will give you the unique id value directly.
For ex, if the request uri is /dynamicpages/708e93
it will return 708e93
.
HttpServletRequest.getRequestURI()
This will give you the entire request url. And you need to parse the unique id properly.
For ex, if the request uri is /dynamicpages/708e93
it will return /dynamicpages/708e93
.