You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by John Rishea <jr...@avaya.com> on 2002/07/23 14:33:57 UTC

Help with chaining servlets via filters

Could someone please point me toward a good resource that shows an example
of chaining two servlets using a filter?  I've found lots of filter examples
during my google searches but none of them shows exactly how to chain two
servlets together with a filter.

Thanks for the help.

__________________
John Rishea


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


RE: Help with chaining servlets via filters

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

On Tue, 23 Jul 2002, John Rishea wrote:

> Date: Tue, 23 Jul 2002 10:09:50 -0600
> From: John Rishea <jr...@avaya.com>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> To: Tomcat Users List <to...@jakarta.apache.org>
> Subject: RE: Help with chaining servlets via filters
>
> Craig,
>
> I have one servlet that runs a unix script using runtime exec to create an
> output file, then a follow-up servlet that takes the output file and
> displays it to a browser window.  The servlets work fine separately but
> don't work when combined into a single servlet.  So I was looking for a way
> to call the display servlet immediately after the script-running servlet
> does its thing.
>
> Any constructive suggestions would be appreciated.

Why can't you just modify the servlet that runs the unix script to copy
the output back to the client after the script executes?

If the second servlet needs to perform modifications in the output format
(such as converting static text into HTML, or performing an XSLT
transformation on an XML file), that's the kind of things that a Filter is
for.  Search Google and java.sun.com for "filter" and you'll find lots of
tutorials, resources, and examples of how to build such a thing.

> __________________
> John Rishea

Craig


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


RE: Help with chaining servlets via filters

Posted by John Rishea <jr...@avaya.com>.
Craig,

I have one servlet that runs a unix script using runtime exec to create an
output file, then a follow-up servlet that takes the output file and
displays it to a browser window.  The servlets work fine separately but
don't work when combined into a single servlet.  So I was looking for a way
to call the display servlet immediately after the script-running servlet
does its thing.

Any constructive suggestions would be appreciated.
__________________
John Rishea

-----Original Message-----
From: Craig R. McClanahan [mailto:craigmcc@apache.org]
Sent: Tuesday, July 23, 2002 9:47 AM
To: Tomcat Users List
Subject: Re: Help with chaining servlets via filters




On Tue, 23 Jul 2002, John Rishea wrote:

> Date: Tue, 23 Jul 2002 06:33:57 -0600
> From: John Rishea <jr...@avaya.com>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> To: Tomcat User Group <to...@jakarta.apache.org>
> Subject: Help with chaining servlets via filters
>
> Could someone please point me toward a good resource that shows an example
> of chaining two servlets using a filter?  I've found lots of filter
examples
> during my google searches but none of them shows exactly how to chain two
> servlets together with a filter.
>

What are you trying to accomplish by "chaining two servlets using a
filter"?  The traditional definition of servlet chaining (feeding the
output of one servlet into another) has turned out to be a very bad design
pattern, so it's not supported.

On the other hand, filters themselves can modify input on the way in, and
output on the way out.  And you can easily configure more than one filter
to be mapped to a particular request.

It all comes down to what you are trying to accomplish.

> Thanks for the help.
>
> __________________
> John Rishea

Craig


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


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


RE: Help with chaining servlets via filters

Posted by Jacob Hookom <ho...@uwec.edu>.
http://www.javaworld.com/javaworld/jw-06-2001/jw-0622-filters.html

Jacob Hookom 
Comprehensive Computer Science 
University of Wisconsin, Eau Claire 


-----Original Message-----
From: Craig R. McClanahan [mailto:craigmcc@apache.org] 
Sent: Tuesday, July 23, 2002 10:47 AM
To: Tomcat Users List
Subject: Re: Help with chaining servlets via filters



On Tue, 23 Jul 2002, John Rishea wrote:

> Date: Tue, 23 Jul 2002 06:33:57 -0600
> From: John Rishea <jr...@avaya.com>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> To: Tomcat User Group <to...@jakarta.apache.org>
> Subject: Help with chaining servlets via filters
>
> Could someone please point me toward a good resource that shows an
example
> of chaining two servlets using a filter?  I've found lots of filter
examples
> during my google searches but none of them shows exactly how to chain
two
> servlets together with a filter.
>

What are you trying to accomplish by "chaining two servlets using a
filter"?  The traditional definition of servlet chaining (feeding the
output of one servlet into another) has turned out to be a very bad
design
pattern, so it's not supported.

On the other hand, filters themselves can modify input on the way in,
and
output on the way out.  And you can easily configure more than one
filter
to be mapped to a particular request.

It all comes down to what you are trying to accomplish.

> Thanks for the help.
>
> __________________
> John Rishea

Craig


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

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.375 / Virus Database: 210 - Release Date: 7/10/2002
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.375 / Virus Database: 210 - Release Date: 7/10/2002
 


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


Re: Help with chaining servlets via filters

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

On Tue, 23 Jul 2002, John Rishea wrote:

> Date: Tue, 23 Jul 2002 06:33:57 -0600
> From: John Rishea <jr...@avaya.com>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> To: Tomcat User Group <to...@jakarta.apache.org>
> Subject: Help with chaining servlets via filters
>
> Could someone please point me toward a good resource that shows an example
> of chaining two servlets using a filter?  I've found lots of filter examples
> during my google searches but none of them shows exactly how to chain two
> servlets together with a filter.
>

What are you trying to accomplish by "chaining two servlets using a
filter"?  The traditional definition of servlet chaining (feeding the
output of one servlet into another) has turned out to be a very bad design
pattern, so it's not supported.

On the other hand, filters themselves can modify input on the way in, and
output on the way out.  And you can easily configure more than one filter
to be mapped to a particular request.

It all comes down to what you are trying to accomplish.

> Thanks for the help.
>
> __________________
> John Rishea

Craig


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