You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by RXZ JLo <ru...@yahoo.com> on 2002/12/09 12:21:25 UTC

RequestDispatcher scenarios ( was RE: static url routing)

--- "Craig R. McClanahan" <cr...@apache.org> wrote:
> To do a redirect filter, then, you'd examine the
> request URI to determine
> what kind of remapping is needed, and then do a
> RequestDispatcher.forward() call to the remapped
> resource name.  After the
> forward returns (which means that the actual
> response has been created),
> simply return instead of calling chain.doFilter() to
> pass the request on.
> 

I am looking for various scenarios where
RequestDispatcher is used. When I searched the list, I
noticed that it can be used in a Servlet too. What
then is the difference between using it in a Filter
and using it in servlet? Can I just use it in the
Servlet to serve my purpose(of serving static
content)?

Thank you
rf.



__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: RequestDispatcher scenarios ( was RE: static url routing)

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Thu, 12 Dec 2002, RXZ JLo wrote:

> >
> > If you're serving your own static content with your
> > own servlet, then you
> > could do this.  Using a Filter lets you use Tomcat's
> > standard static file
> > serving servlet with no modifications.
>
>
> It seems I am confused about how RequestDispatcher
> works. From what I understand I think using a
> RequestDispatcher from within a Servlet or a Filter,
> is same - the request is viewed as a fresh request
> appropriately handled by Tomcat. This means, when I
> use RequestDispatcher(static_url).forward()+return in
> a servlet, it is the tomcat that is serving the static
> url, and in the same way as directly requested static
> urls.
>
> "If you're serving your own static content with your
> own servlet, then you could do this." -- I want
> RequestDispatcher to handle serving the static content
> in my own servlet.

Your understanding of how request dispatchers work is essentially correct.
I was pointing out that it's *possible* to implement redirection to
standard static resources using a filter.  Using your own servlets to
handle the static resources is also possible - just make sure that the
URLs you forward to are mapped to your servlet.

>
> Please clarify.
> Thanks,
> rf.
>

Craig


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: RequestDispatcher scenarios ( was RE: static url routing)

Posted by RXZ JLo <ru...@yahoo.com>.
--- "Craig R. McClanahan" <cr...@apache.org> wrote:
> 
> 
> On Mon, 9 Dec 2002, RXZ JLo wrote:
> 
> > Date: Mon, 9 Dec 2002 03:21:25 -0800 (PST)
> > From: RXZ JLo <ru...@yahoo.com>
> > Reply-To: Tomcat Users List
> <to...@jakarta.apache.org>
> > To: Tomcat Users List
> <to...@jakarta.apache.org>
> > Subject: RequestDispatcher scenarios ( was RE:
> static url routing)
> >
> >
> > --- "Craig R. McClanahan" <cr...@apache.org>
> wrote:
> > > To do a redirect filter, then, you'd examine the
> > > request URI to determine
> > > what kind of remapping is needed, and then do a
> > > RequestDispatcher.forward() call to the remapped
> > > resource name.  After the
> > > forward returns (which means that the actual
> > > response has been created),
> > > simply return instead of calling
> chain.doFilter() to
> > > pass the request on.
> > >
> >
> > I am looking for various scenarios where
> > RequestDispatcher is used. When I searched the
> list, I
> > noticed that it can be used in a Servlet too. What
> > then is the difference between using it in a
> Filter
> > and using it in servlet? Can I just use it in the
> > Servlet to serve my purpose(of serving static
> > content)?
> >
> 
> If you're serving your own static content with your
> own servlet, then you
> could do this.  Using a Filter lets you use Tomcat's
> standard static file
> serving servlet with no modifications.


It seems I am confused about how RequestDispatcher
works. From what I understand I think using a
RequestDispatcher from within a Servlet or a Filter,
is same - the request is viewed as a fresh request
appropriately handled by Tomcat. This means, when I
use RequestDispatcher(static_url).forward()+return in
a servlet, it is the tomcat that is serving the static
url, and in the same way as directly requested static
urls.

"If you're serving your own static content with your
own servlet, then you could do this." -- I want
RequestDispatcher to handle serving the static content
in my own servlet.

Please clarify.
Thanks,
rf.

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: RequestDispatcher scenarios ( was RE: static url routing)

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Mon, 9 Dec 2002, RXZ JLo wrote:

> Date: Mon, 9 Dec 2002 03:21:25 -0800 (PST)
> From: RXZ JLo <ru...@yahoo.com>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> To: Tomcat Users List <to...@jakarta.apache.org>
> Subject: RequestDispatcher scenarios ( was RE: static url routing)
>
>
> --- "Craig R. McClanahan" <cr...@apache.org> wrote:
> > To do a redirect filter, then, you'd examine the
> > request URI to determine
> > what kind of remapping is needed, and then do a
> > RequestDispatcher.forward() call to the remapped
> > resource name.  After the
> > forward returns (which means that the actual
> > response has been created),
> > simply return instead of calling chain.doFilter() to
> > pass the request on.
> >
>
> I am looking for various scenarios where
> RequestDispatcher is used. When I searched the list, I
> noticed that it can be used in a Servlet too. What
> then is the difference between using it in a Filter
> and using it in servlet? Can I just use it in the
> Servlet to serve my purpose(of serving static
> content)?
>

If you're serving your own static content with your own servlet, then you
could do this.  Using a Filter lets you use Tomcat's standard static file
serving servlet with no modifications.

> Thank you
> rf.

Craig



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>