You won't be able to get the servlet reference. A possibility is to define the filter multiple times with different parameters. For example, here is the same class name defined 4 times as 4 different filters.

<filter>
  <filter-name>filter1</filter-name>
  <filter-class>more.Cowbell</filter-class>
  <init-param>
    <param-name>my</param-name>
    <param-value>attribute</param-value>
  </init-param>
</filter>
<filter>
  <filter-name>filter2</filter-name>
  <filter-class>more.Cowbell</filter-class>
</filter>
<filter>
  <filter-name>filter3</filter-name>
  <filter-class>more.Cowbell</filter-class>
  <init-param>
    <param-name>another</param-name>
    <param-value>some value</param-value>
  </init-param>
</filter>
<filter>
  <filter-name>filter4</filter-name>
  <filter-class>more.Cowbell</filter-class>
</filter>

I'll leave it up to you to figure out the mappings according to your constraints.

-Tim

Seth Ladd wrote:

Hello,

I don't think this is possible, but I'm giving it a shot anyway. :)

I'd like to get ahold of a servlet reference from within a filter. Is there a way?

I have a filter that creates objects and places them within the request scope, but it does it differently for each end-result servlet. I'd like the filter to look at the URI, determine the servlet, and grab the servlet. Then, it can either grab its init-params or just call a special method to get the data it needs.

Now, this idea might be broken to begin with. The other idea is to just create a super class for the servlet and handle this base logic from there. If I can use a filter, though, that would be great.

Any tips or hints? I hope I wasn't too vague.



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to