> -----Original Message-----
> From: RXZ JLo [mailto:[EMAIL PROTECTED]]
> Sent: Friday, December 13, 2002 8:31 AM
> To: Tomcat Users List
> Subject: RE: RequestDispatcher scenarios ( was RE: static url routing)
> 
> 
> 
> --- "Cox, Charlie" <[EMAIL PROTECTED]> wrote:
> > RequestDisatcher is for dispatching (parts of)the
> > current request to other
> > resources in the same context without involving the
> > browser. This means that
> > it is not a new request(filters/valves/etc do not
> > get invoked), but it is
> > processed by the servlet/filter just like a request
> > directly to the
> > servlet/filter
> > 
> 
> 
> Lets say in my servlet I modify the HttpServletRequest
> changing the url to a statically accessible file, and
> pass it on to RequestDispatcher.forward. Now, does the
> DefaultServlet handle the static file?
> 

yes. servlet mappings are processed again, but not filter mappings

> 
> 
> > The DefaultServlet handles static content. This is
> > not part of your servlet,
> > it is its own built-in servlet. If you need to
> > modify behavior(custom
> > auth,etc) then you can set up a filter that is
> > mapped to the static content.
> > 
> > for example:
> > 
> > the following mapping will cause 'MyFilter' to be
> > run for any file requested
> > from the /images directory. If you do not set up a
> > custom servlet to handle
> > /images/*, then the DefaultServlet will serve the
> > request file from your
> > 'images' directory provided your filter does not
> > intercept the request(i.e.
> > redirect to a login page).
> 
> 
> You have not told why we cannot do this in a Servlet
> using the RequestDispatcher.forward.
> 

you could use a servlet for this, but that's what filters are for. They
allow you to perform logic to see if your servlet should even run. Calling
forward() from either has the same effect.

This is how I see your question: you have a request that comes in,
/mydir/somefile, that is mapped to your servlet. Within your servlet you are
using some logic to determine if the servlet should continue to serve its
content or use RequestDispatcher.forward() to serve a static file(say a
custom login page). Is this correct?

This is what I use the filter for. I originally used a servlet until I
wanted to protect more than one servlet(including some content served by
defaultservlet) with my custom auth. So I changed my code to a filter so
that the servlet(my servlet or defaultservlet) does not get called unless it
should serve something.

If you feel that a servlet is better for your app, go right ahead and
implement it in a servlet.

Charlie

> 
> Btw, If you feel I am dragging this topic on too much
> please say so - I would know I have not put down my
> question properly.
> 
> Thank you,
> -rf
> 
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
> 
> --
> To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

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

Reply via email to