I have to filter urls like this :
http://www.mysite.com/708e93
where 708e93 is a unique id, based on this id i have to create dynamic pages in jsp.
Now the problem is – what do i put in url-pattern under filter-mapping
<filter-mapping>
<filter-name>foo.bar.MyFilter</filter-name>
<url-pattern> ?? </url-pattern>
</filter-mapping>
if i put root (/) in url-pattern ..every request to mysite will be filtered ,then in that case how can i get unique id ?
Any solution ?
EDIT:
I dont want to add a directory in url like this :http://www.mysite.com/dynamicpages/708e93
For dynamic url’s such as use case you have. you should be have all the dynamic pages inside a directory, lets say
dynamicpagesfolder. And you should be mapping a directory url pattern like below :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/708e93it 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/708e93it will return
/dynamicpages/708e93.