-
1. Re: Using filtering techniques with JBoss 3.2.5
jleech Jul 8, 2004 6:25 PM (in response to hcam)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
hcam Jul 9, 2004 12:43 PM (in response to hcam)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("<html><head></head><body>"); out.println("<h1>Sorry, page cannot be displayed!</h1>"); out.println("</body></html>"); out.flush(); return; } chain.doFilter(request, response); } public void destroy() { } public void init(FilterConfig filterConfig) { this.filterConfig = filterConfig; } }
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>IE Filter</filter-name> <filter-class>com.ibm.devworks.filters.IEFilter</filter-class> </filter> <filter-mapping> <filter-name>IE Filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>
WebApp structure (dvworks.war):C:\jboss-3.2.5\server\default\deploy -dvworks.war -index.html -WEB-INF -web.xml -classes -com -ibm -devworks -filters -IEFilter.class
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
jleech Jul 9, 2004 3:23 PM (in response to hcam)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
hcam Jul 9, 2004 4:15 PM (in response to hcam)Hi J. Leech
Got it !!!!!
Really, many thanks to you.
FYI:
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.
Regards,
H.C.