Re: Is it possible to intercept all requests and be serviced by a ser vlet?

2004-05-18 Thread Tim Funk
You can use a Valve.
Or you can use a Filter configured in $CATALINA_HOME/conf/server.xml and the 
class would live in the common/ classloader

-Tim
Chippada, Sreeni wrote:
Hi,
 I am using Tomcat 5. I need all the requests be serviced by a
particular servlet irrespective of the web apps deployed. Is there a way to
do it?
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: Is it possible to intercept all requests and be serviced by a ser vlet?

2004-05-18 Thread Chippada, Sreeni
Hi Tim,
Thanks for your reply.
I know how to create a valve. But I do not know how to execute a
servlet from a valve. I will be glad if you can you can tell me how to ro
point me to appropriate resources.

Also, I do not know how to configure the filters in the server.xml.
Appreciate any help.

Thanks,
Sreeni

-Original Message-
From: Tim Funk [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 18, 2004 7:50 AM
To: Tomcat Users List
Subject: Re: Is it possible to intercept all requests and be serviced by a
ser vlet?

You can use a Valve.

Or you can use a Filter configured in $CATALINA_HOME/conf/server.xml and the

class would live in the common/ classloader

-Tim

Chippada, Sreeni wrote:
 Hi,
  I am using Tomcat 5. I need all the requests be serviced by a
 particular servlet irrespective of the web apps deployed. Is there a way
to
 do it?

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

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



Re: Is it possible to intercept all requests and be serviced by a ser vlet?

2004-05-18 Thread Tim Funk
It sounds like using a Filter would be easier. With a filter - you can use 
the Servlet API to get a Dispatcher for the servlet you wish to call. For 
example, this filter reroute all requests to  FooServlet:

package more.cowbell;
import javax.servlet.Filter;
import javax.servlet.FilterConfig;
import javax.servlet.FilterChain;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.ServletException;
import java.io.IOException;
public class ReRouteFilter implements Filter {
public void init(FilterConfig filterConfig) throws ServletException {
;
}
   public void doFilter(ServletRequest request,
ServletResponse response,
FilterChain chain)
  throws IOException, ServletException {
  request.getRequestDispatcher(/FooServlet).forward(request, response);
   }
   public void destroy() {
   ;
   }
}
---
Then in $CATALINA_HOME/conf/web.xml
filter
filter-nameReRoute Filter/filter-name
filter-classmore.cowbell.ReRouteFilter/filter-class
/filter
!-- Trap everything going to the default servlet--
filter-mapping
filter-nameReRoute Filter/filter-name
servlet-namedefault/servlet-name
/filter-mapping
!-- Trap by file extension html--
filter-mapping
filter-nameReRoute Filter/filter-name
url-pattern*.html/url-pattern
/filter-mapping
---
-Tim
Chippada, Sreeni wrote:
Hi Tim,
Thanks for your reply.
I know how to create a valve. But I do not know how to execute a
servlet from a valve. I will be glad if you can you can tell me how to ro
point me to appropriate resources.
Also, I do not know how to configure the filters in the server.xml.
Appreciate any help.
Thanks,
Sreeni
-Original Message-
From: Tim Funk [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 18, 2004 7:50 AM
To: Tomcat Users List
Subject: Re: Is it possible to intercept all requests and be serviced by a
ser vlet?

You can use a Valve.
Or you can use a Filter configured in $CATALINA_HOME/conf/server.xml and the
class would live in the common/ classloader
-Tim
Chippada, Sreeni wrote:
Hi,
I am using Tomcat 5. I need all the requests be serviced by a
particular servlet irrespective of the web apps deployed. Is there a way
to
do it?
 
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: Is it possible to intercept all requests and be serviced by a ser vlet?

2004-05-18 Thread Chippada, Sreeni
That will solve my issue.

Thank you very much,
Sreeni

-Original Message-
From: Tim Funk [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 18, 2004 10:18 AM
To: Tomcat Users List
Subject: Re: Is it possible to intercept all requests and be serviced by a
ser vlet?

It sounds like using a Filter would be easier. With a filter - you can use 
the Servlet API to get a Dispatcher for the servlet you wish to call. For 
example, this filter reroute all requests to  FooServlet:

package more.cowbell;

import javax.servlet.Filter;
import javax.servlet.FilterConfig;
import javax.servlet.FilterChain;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.ServletException;
import java.io.IOException;

public class ReRouteFilter implements Filter {

 public void init(FilterConfig filterConfig) throws ServletException {
 ;
 }

public void doFilter(ServletRequest request,
 ServletResponse response,
 FilterChain chain)
   throws IOException, ServletException {
   request.getRequestDispatcher(/FooServlet).forward(request,
response);
}

public void destroy() {
;
}
}

---
Then in $CATALINA_HOME/conf/web.xml
 filter
 filter-nameReRoute Filter/filter-name
 filter-classmore.cowbell.ReRouteFilter/filter-class
 /filter
 !-- Trap everything going to the default servlet--
 filter-mapping
 filter-nameReRoute Filter/filter-name
 servlet-namedefault/servlet-name
 /filter-mapping
 !-- Trap by file extension html--
 filter-mapping
 filter-nameReRoute Filter/filter-name
 url-pattern*.html/url-pattern
 /filter-mapping
---

-Tim

Chippada, Sreeni wrote:

 Hi Tim,
   Thanks for your reply.
   I know how to create a valve. But I do not know how to execute a
 servlet from a valve. I will be glad if you can you can tell me how to ro
 point me to appropriate resources.
 
   Also, I do not know how to configure the filters in the server.xml.
 Appreciate any help.
 
 Thanks,
 Sreeni
 
 -Original Message-
 From: Tim Funk [mailto:[EMAIL PROTECTED] 
 Sent: Tuesday, May 18, 2004 7:50 AM
 To: Tomcat Users List
 Subject: Re: Is it possible to intercept all requests and be serviced by a
 ser vlet?
 
 You can use a Valve.
 
 Or you can use a Filter configured in $CATALINA_HOME/conf/server.xml and
the
 
 class would live in the common/ classloader
 
 -Tim
 
 Chippada, Sreeni wrote:
 
Hi,
 I am using Tomcat 5. I need all the requests be serviced by a
particular servlet irrespective of the web apps deployed. Is there a way
 
 to
 
do it?
 
  

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

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



Is it possible to intercept all requests and be serviced by a ser vlet?

2004-05-17 Thread Chippada, Sreeni
Hi,
 I am using Tomcat 5. I need all the requests be serviced by a
particular servlet irrespective of the web apps deployed. Is there a way to
do it?

Thanks,
Sreeni

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



Re: Is it possible to intercept all requests and be serviced by a ser vlet?

2004-05-17 Thread QM
On Mon, May 17, 2004 at 10:19:29PM -0400, Chippada, Sreeni wrote:
:  I am using Tomcat 5. I need all the requests be serviced by a
: particular servlet irrespective of the web apps deployed. Is there a way to
: do it?

Have you tried putting it in the global web.xml?  Not 
{context}/WEB-INF/web.xml

I mean the one in
{tomcat install}/conf/web.xml


What that means as far as classloading issues, and whether all webapps
will see the *same instance* of that servlet class, I can't tell you...
but I'm sure that's in the docs.


A more portable solution would be to just include that same servlet in
each webapp, but you know your app/setup better than I...

-QM

-- 

software  -- http://www.brandxdev.net
tech news -- http://www.RoarNetworX.com


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