tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anto Paul <antop...@gmail.com>
Subject Re: Servlet mapping problem
Date Wed, 29 Sep 2004 14:06:15 GMT
What if I use a filter ?. I will map it like this

    <filter-mapping>
        <filter-name>MappingFilter</filter-name>
        <url-pattern>/</url-pattern>
    </filter-mapping>

     <filter-mapping>
        <filter-name>MappingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

In filter I forward to the path substituted with the directory. With
servlet I failed to achieve what I want. I am sceptical about using a
forward in a filter. This filter is the only filter that exists in the
application. Even if another filter is added it can be put as he last
filter in web.xml. Please comment on this.

rgds
Anto Paul 


On Wed, 29 Sep 2004 09:04:32 -0400, Shapira, Yoav <yoav.shapira@mpi.com> wrote:
> 
> Hi,
> 
> >However, I am sure about the fact, that you cannot map a single url
> such as
> >"/".
> >(Yes, you can define a mapping of "/", but that maps to EVERY request,
> NOT
> >to the root url only.)
> 
> No.  You're mistaking the default configuration for something that's
> hard-coded.  Out of the box, "/" is mapped to Tomcat's DefaultServlet,
> which handles static content.  This is routine for other containers as
> well and is not a particular Tomcat trick.
> 
> Per the servlet spec, / is the default mapping also, so anything that's
> not matched by other mappings will end up there.
> 
> So, here's one way to change things:
> - Explicitly map the things you want handled by Tomcat's DefaultServlet
> to it, e.g.
> <servlet-name>DefaultServlet</servlet-name><url-pattern>*.html</url-patt
> ern>.  Same for *.htm, *.gif, *.jpg, *.png, etc.
> - Map any servlet of your choice to URL pattern /.
> - Ensure that rest of your app has no unmapped pages, i.e. ones that'll
> propagate to /.
> 
> 
> 
> Yoav
> 
> This e-mail, including any attachments, is a confidential business communication, and
may contain information that is confidential, proprietary and/or privileged.  This e-mail
is intended only for the individual(s) to whom it is addressed, and may not be saved, copied,
printed, disclosed or used by anyone else.  If you are not the(an) intended recipient, please
immediately delete this e-mail from your computer system and notify the sender.  Thank you.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 



-- 
To strive,to seek,to find and not to yield

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message