Hi ranchers, I got a question for you.
in web.xml config file I configured a set of servlets with an init-param (let's call it OP_CODE). Each servlet has its own OP_CODE. Now, since the logic that handles this param is the same for each servlets, I'd like to move this logic to a filter. What I need to know is : is there a way to retrieve the configured value of the OP_CODE param from the filter code, starting from the requested URL ?
I'll try to be a bit more clear:
You may need to put your param in the request or response. Or you may build an xml or property file and read it when the web application starts through ContextListener then put it into ServletContext. The map contains the Servlet name as key and the OP_CODE as the value.
You can get the ServletContext through the FilterConfig
How can you move the value as a context parameter when there are more than just one value ?
Mine was just an example, but the real case is like this :
So, there can be n servlets, each with its own OP_CODE param. The check on the OP_CODE value is the same for every servlet, that's why I'm using a filter (by now I pass the OP_CODE value as a request variable, but it's kinda dirty in my opinion). I'm also thinking to remove the filter and let all my servlets to extend an unique one which will do the same logic in her service method. (although I kinda liked the idea of a filter).