You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jonathan Holloway <to...@eudoramail.com> on 2001/08/21 15:52:14 UTC
Multiple Url Patterns
I have a number of servlets deployed in a web application under tomcat,
one of these servlets is specifically accessed as follows:
http://localhost/servlets/exampleServlet
My problem is that I need to access exactly the same servlet but using a
different
url pattern, i.e. this one
http://localhost/exampleServlet
Is it possible to deploy a servlet under two pattern. i.e. as follows in
the web.xml
file under the servlet mapping..
<servlet-mapping>
<servlet-name>exampleServlet</servlet-name>
<url-pattern>/servlets/exampleServlet/*</url-pattern>
<url-pattern>/exampleServlet/*</url-pattern>
</servlet-mapping>
I've tried it like this but have been unable to get it to work and I need
to do this for
backwards compatibility onyl. Is it possible to do this any other way if
not possible
in this way?
Jonathan Holloway.
Re: Multiple Url Patterns
Posted by Johannes Lehtinen <jl...@cc.hut.fi>.
On Tue, 21 Aug 2001, Jonathan Holloway wrote:
> My problem is that I need to access exactly the same servlet but using
> a different url pattern.
...
> Is it possible to deploy a servlet under two pattern. i.e. as follows
Does it matter if you get two instances of the same servlet? If two
instances is ok then you can include two <servlet></servlet> sections
using the same servlet-class but different servlet-name and map these two
two different URLs.
The Deployment Descriptor DTD seems to allow only one url-pattern in
servlet-mapping (reading the servlet 2.2 spec).
--
Johannes Lehtinen <jo...@iki.fi>, http://www.iki.fi/jle/
Re: Multiple Url Patterns
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Tue, 21 Aug 2001, Jonathan Holloway wrote:
> I have a number of servlets deployed in a web application under tomcat,
> one of these servlets is specifically accessed as follows:
>
> http://localhost/servlets/exampleServlet
>
> My problem is that I need to access exactly the same servlet but using a
> different
> url pattern, i.e. this one
>
> http://localhost/exampleServlet
>
> Is it possible to deploy a servlet under two pattern. i.e. as follows in
> the web.xml
> file under the servlet mapping..
>
> <servlet-mapping>
> <servlet-name>exampleServlet</servlet-name>
> <url-pattern>/servlets/exampleServlet/*</url-pattern>
> <url-pattern>/exampleServlet/*</url-pattern>
> </servlet-mapping>
>
You cannot do this in one mapping, but you can do it in two:
<servlet-mapping>
<servlet-name>exampleServlet</servlet-name>
<url-pattern>/servlets/exampleServlet/*</url-pattern>
</servlet-maping>
<servlet-mapping>
<servlet-name>exampleServlet</servlet-name>
<url-pattern>/exampleServlet/*</url-pattern>
</servlet-mapping>
There's no limit on the number of different mappings you can point at the
same <servlet> definition.
> I've tried it like this but have been unable to get it to work and I need
> to do this for
> backwards compatibility onyl. Is it possible to do this any other way if
> not possible
> in this way?
>
> Jonathan Holloway.
>
>
Craig