Setting up a filter based on server name

Discussion in 'Java' started by MarkN, Oct 27, 2004.

  1. MarkN

    MarkN Guest

    This question pertains to the Java Servlet specification.

    Is it possible to specify a <url-pattern> for a filter based on the
    server name?
    Trying to specify a url-pattern such as "www.bla.com/*" doesn't work.
    Am I missing something here or am I trying to do something that is not
    supported.


    Example (that does not work as intended):

    <filter>
    <filter-name>TF</filter-name>
    <filter-class>TestFilter</filter-class>
    </filter>


    <filter-mapping>
    <filter-name>TF</filter-name>
    <url-pattern>www.bla.com/*</url-pattern>
    </filter-mapping>


    Thanks for your time!
    MarkN, Oct 27, 2004
    #1
    1. Advertising

  2. MarkN

    Mike H Guest

    I'm assuming you're virtual hosting. Each virtual host has it's own
    and each host has its own web.xml file. It's in the web.xml for the
    particular host where you define the filter url-pattern that is
    relational to the virtual host. Unless I'm missing something.


    On 27 Oct 2004 15:20:51 -0700, (MarkN) wrote:

    >This question pertains to the Java Servlet specification.
    >
    >Is it possible to specify a <url-pattern> for a filter based on the
    >server name?
    >Trying to specify a url-pattern such as "www.bla.com/*" doesn't work.
    >Am I missing something here or am I trying to do something that is not
    >supported.
    >
    >
    >Example (that does not work as intended):
    >
    > <filter>
    > <filter-name>TF</filter-name>
    > <filter-class>TestFilter</filter-class>
    > </filter>
    >
    >
    > <filter-mapping>
    > <filter-name>TF</filter-name>
    > <url-pattern>www.bla.com/*</url-pattern>
    > </filter-mapping>
    >
    >
    >Thanks for your time!
    Mike H, Oct 28, 2004
    #2
    1. Advertising

  3. MarkN

    MarkN Guest

    My situation is unique I guess. There are several virtual hosts tied
    to the same J2EE application (ColdFusionMX running on top of JRun4).


    Mike H <> wrote in message news:<>...
    > I'm assuming you're virtual hosting. Each virtual host has it's own
    > and each host has its own web.xml file. It's in the web.xml for the
    > particular host where you define the filter url-pattern that is
    > relational to the virtual host. Unless I'm missing something.
    >
    >
    > On 27 Oct 2004 15:20:51 -0700, (MarkN) wrote:
    >
    > >This question pertains to the Java Servlet specification.
    > >
    > >Is it possible to specify a <url-pattern> for a filter based on the
    > >server name?
    > >Trying to specify a url-pattern such as "www.bla.com/*" doesn't work.
    > >Am I missing something here or am I trying to do something that is not
    > >supported.
    > >
    > >
    > >Example (that does not work as intended):
    > >
    > > <filter>
    > > <filter-name>TF</filter-name>
    > > <filter-class>TestFilter</filter-class>
    > > </filter>
    > >
    > >
    > > <filter-mapping>
    > > <filter-name>TF</filter-name>
    > > <url-pattern>www.bla.com/*</url-pattern>
    > > </filter-mapping>
    > >
    > >
    > >Thanks for your time!
    MarkN, Oct 29, 2004
    #3
  4. MarkN

    freddiemac Guest

    What do you mean servers "tied to" an application?
    HTTPServletRequest.getRequestURL() should give you what you need.

    MarkN wrote:
    > My situation is unique I guess. There are several virtual hosts tied
    > to the same J2EE application (ColdFusionMX running on top of JRun4).
    >
    >
    > Mike H <> wrote in message news:<>...
    >
    >>I'm assuming you're virtual hosting. Each virtual host has it's own
    >>and each host has its own web.xml file. It's in the web.xml for the
    >>particular host where you define the filter url-pattern that is
    >>relational to the virtual host. Unless I'm missing something.
    >>
    >>
    >>On 27 Oct 2004 15:20:51 -0700, (MarkN) wrote:
    >>
    >>
    >>>This question pertains to the Java Servlet specification.
    >>>
    >>>Is it possible to specify a <url-pattern> for a filter based on the
    >>>server name?
    >>>Trying to specify a url-pattern such as "www.bla.com/*" doesn't work.
    >>>Am I missing something here or am I trying to do something that is not
    >>>supported.
    >>>
    >>>
    >>>Example (that does not work as intended):
    >>>
    >>> <filter>
    >>> <filter-name>TF</filter-name>
    >>> <filter-class>TestFilter</filter-class>
    >>> </filter>
    >>>
    >>>
    >>> <filter-mapping>
    >>> <filter-name>TF</filter-name>
    >>> <url-pattern>www.bla.com/*</url-pattern>
    >>> </filter-mapping>
    >>>
    >>>
    >>>Thanks for your time!

    >>
    freddiemac, Oct 29, 2004
    #4
  5. MarkN

    Sudsy Guest

    freddiemac wrote:
    > What do you mean servers "tied to" an application?
    > HTTPServletRequest.getRequestURL() should give you what you need.
    >
    > MarkN wrote:
    >
    >> My situation is unique I guess. There are several virtual hosts tied
    >> to the same J2EE application (ColdFusionMX running on top of JRun4).


    I know what OP means: rather than creating a separate code base for
    each virtual host, they share a common one. A potentially disastrous
    approach, IMHO.

    --
    Java/J2EE/JSP/Struts/Tiles/C/UNIX consulting and remote development.
    Sudsy, Oct 30, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. RockNRoll
    Replies:
    1
    Views:
    3,434
    Raterus
    Aug 2, 2004
  2. ding feng
    Replies:
    2
    Views:
    2,801
    ding feng
    Jun 25, 2003
  3. zax75
    Replies:
    1
    Views:
    1,094
  4. codeFlick
    Replies:
    1
    Views:
    101
    Aaron Bertrand [SQL Server MVP]
    Aug 8, 2005
  5. Collin Moore
    Replies:
    2
    Views:
    107
    Bertram Scharpf
    Oct 15, 2009
Loading...

Share This Page