tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Jones" <kev...@develop.com>
Subject RE: do filters work ...
Date Fri, 02 Feb 2001 21:18:27 GMT
I have filters working fine on TC 4.0b1

Is demo the name of your web application?

If so your web.xml file should look like this

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

    <filter-mapping>
       <filter-name>helloWorld</filter-name>
       <url-pattern>/hello.jsp</url-pattern>
    </filter-mapping>

Even if demo is asubdirectory I would try the first filter mapping here
(i.e. filter everything) and see if that works,


Kevin Jones
DevelopMentor
www.develop.com

> -----Original Message-----
> From: Grobe, Gary [mailto:Gary_Grobe@bmc.com]
> Sent: 02 February 2001 18:27
> To: 'tomcat-dev@jakarta.apache.org'
> Subject: do filters work ...
>
>
> I'm sending this to the dev group since I'm dealing w/ tomcat4.0
> (catalina)
> issues and not sure how far along filters are. I can't seem to get my
> filters to work so I have a basic HelloWorld that I'm using. The output of
> the jsp is what my problem is.
>
>
> Everything seems to come up fine (running in stand-alone)
>
> ~/logs/catalina.out shows:
> ---- catalina.out ---------------------------
> Starting service Tomcat-Apache
> Apache Tomcat/4.0-b1
>
> A shutdown would show:
>
> Stopping service Tomcat-Standalone
> Stopping service Tomcat-Apache
> Starting service Tomcat-Standalone
> Apache Tomcat/4.0-b1
>
>
> In my ~logs/localhost_access*, the first GET (of my ~/demo/hello.jsp)
> returns a 200 (after that it's a 302, anyway to force a non-cached GET?).
>
> --------------------------------------------
>
> The output of the hello.jsp:
>
> _________________ this is supposed to be an <hr>
>
> null
>
> Check console output!
>
> _________________ this is supposed to be an <hr>
>
>
> ----------------- my hello.jsp ---------------------
>
> <html>
> <head>
>    <title>Testing Filters</title>
> </head>
>
> <body>
>    <hr>
>       <p><%=request.getAttribute("hello")%></p>
>       <p>Check console output!</p>
>    <hr>
> </body>
> </html>
>
> ------------ my filter HelloWorld.java ------
>
> package filters;
>
> import javax.servlet.*;
>
> public class HelloWorld extends GenericFilter
> {
>    private FilterConfig FilterConfig;
>
>    public void doFilter(final ServletRequest request,
>          final ServletResponse response,
>          FilterChain chain) throws java.io.IOException,
>          javax.servlet.ServletException {
>
>       System.out.println("Entering HelloWorld Filter");
>
>       request.setAttribute("hello", "Hello World!");
>
>       chain.doFilter(request, response);
>
>       System.out.println("Entering HelloWorld Filter");
>
>    }
> }
>
> -------- my generic filter GenericFilter.java ---------
>
> package filters;
>
> import javax.servlet.*;
>
> public class GenericFilter implements javax.servlet.Filter
> {
>    private FilterConfig filterConfig;
>
>    public void doFilter(final ServletRequest request,
>          final ServletResponse response,
>          FilterChain chain)
>          throws java.io.IOException, javax.servlet.ServletException {
>
>       chain.doFilter(request, response);
>    }
>
>    public void setFilterConfig(final FilterConfig filterConfig) {
>       this.filterConfig = filterConfig;
>    }
>
>    public FilterConfig getFilterConfig() {
>       return filterConfig;
>    }
> }
>
> ---------------- my web.xml ------------------------
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <!DOCTYPE web-app
>    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
>    "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
>
> <web-app>
>
>    <filter>
>       <filter-name>prePost</filter-name>
>       <filter-class>filters.PrePostFilter</filter-class>
>    </filter>
>
>    <filter>
>       <filter-name>helloWorld</filter-name>
>       <filter-class>filters.HelloWorld</filter-class>
>    </filter>
>
>    <filter-mapping>
>       <filter-name>prePost</filter-name>
>       <url-pattern>/demo/*</url-pattern>
>    </filter-mapping>
>
>    <filter-mapping>
>       <filter-name>helloWorld</filter-name>
>       <url-pattern>/demo/hello.jsp</url-pattern>
>    </filter-mapping>
>
>    <!--servlet>
>       <servlet-name>InsertApp</servlet-name>
>       <servlet-class>servlets.insertapp.InsertApp</servlet-class>
>          <init-param>
>          <param-name>debug</param-name>
>          <param-value>2</param-value>
>       </init-param>
>    </servlet>
>
>    <servlet-mapping>
>       <servlet-name>InsertApp</servlet-name>
>       <url-pattern>/InsertApp</url-pattern>
>    </servlet-mapping-->
>
> </web-app>
>
> ----------------------------------------------------
>
> On a side note: any docs on configuring catalinas, like, how to get it out
> of stand-alone mode, and the configuration differences is has of previous
> tomcat's (i.e. httpd.conf, etc...)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-dev-help@jakarta.apache.org


Mime
View raw message