4 Replies Latest reply on Jul 9, 2004 4:15 PM by Henri CAJAL

    Using filtering techniques with JBoss 3.2.5

    Henri CAJAL Newbie

      As part of Java Servlet 2.3 specs, it is possible to use the filtering feature in web applications.
      While I've been able to use this technique under Tomcat 4.1.30, I'm not able to be successful under JBoss 3.2.5.
      Based on filtering examples provided within the Tomcat release (...\webapps\examples\WEB-INF\classes\filters) or the one from Sing Li (http://www-106.ibm.com/developerworks/java/library/j-tomcat), I've deployed my sample classes and defined the necessary filter tags in the web.xml file.
      Starting my server is ok (in case of mistake, e.g. bad tag declaration, servlet class not in CLASSPATH, this would be mentionned in the log).
      Any request sent to the server works like if filtering is not taken in account.

      So, my question is:
      Is there any configuration operation to do under JBoss in order to filtering take effect?
      Does some logging setting, for example the presence of log4j, would take precedence on filtering and then might disable this feature?

      Thanks for help

        • 1. Re: Using filtering techniques with JBoss 3.2.5
          Jonathan Leech Newbie

          I'm using filters without problem in JBoss 3.2.5. Do you have the filter-mapping set properly in web.xml?

          • 2. Re: Using filtering techniques with JBoss 3.2.5
            Henri CAJAL Newbie

            J. Leech
            Thanks a lot for taking care of my concern.
            Having seen that it whas properly doable, I've done more research and get it partially working.
            In fact, it works at the webapp level but I'd like to get the filtering applied to every hhtp request (I mean all jsp/serlets which are accessible on my server).
            Let's come back to a simple example (IEFilter from Sing Li - link given in my initial post).
            This filter checks the browser used to connect the server:
            -If IE: Sorry, page cannot be displayed!
            -If another (Firefox): A Sample Index File... blabla

            Servlet source (IEFilter.class):

            package com.ibm.devworks.filters;
            import java.io.*;
            import javax.servlet.*;
            import javax.servlet.http.*;
            public final class IEFilter implements Filter {
             private FilterConfig filterConfig = null;
             public void doFilter(ServletRequest request, ServletResponse response,
             FilterChain chain)
             throws IOException, ServletException {
             String browserDet = ((HttpServletRequest) request).getHeader("User-Agent").toLowerCase();
             if ( browserDet.indexOf("msie") != -1) {
             PrintWriter out = response.getWriter();
             out.println("<h1>Sorry, page cannot be displayed!</h1>");
             chain.doFilter(request, response);
             public void destroy() {
             public void init(FilterConfig filterConfig) {
             this.filterConfig = filterConfig;

            <?xml version="1.0" encoding="ISO-8859-1"?>
            <!DOCTYPE web-app
             PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
             <filter-name>IE Filter</filter-name>
             <filter-name>IE Filter</filter-name>

            WebApp structure (dvworks.war):

            Invoking http://localhost:8080/dvworks/index.html gives the expected results.

            What I try to do without any success until now is to get this filter applied to any http request done on my server.
            I have put the com.ibm...IEFilter.class in C:\jboss-3.2.5\server\default\deploy\http-invoker.sar\invoker.war\WEB-INF\classes
            and inserted my filter in C:\jboss-3.2.5\server\default\deploy\http-invoker.sar\invoker.war\WEB-INF.web.xml
            but the mistake might be there, it has no effect on html/jsp pages I have under my docroot.war.
            Perhaps I have to do that job in another place.

            Thanks again for giving me some light.

            • 3. Re: Using filtering techniques with JBoss 3.2.5
              Jonathan Leech Newbie

              Try configuring your filter in deploy\jbossweb-tomcat50.sar\web.xml instead. According to the comments at the top of the file it applies to all webapps. Put the necessary class files in a .jar file in the lib directory.

              • 4. Re: Using filtering techniques with JBoss 3.2.5
                Henri CAJAL Newbie

                Hi J. Leech

                Got it !!!!!
                Really, many thanks to you.

                I've spend lot of time searching the web for filtering infos.
                I've just registered this forum yesterday and did my first post.
                The day after, you did solve my issue.
                I think there are great guys here and I want to thank you again.