[opencms-dev] How to use filters in OpenCMS module

Claus Priisholm cpr at codedroids.com
Wed Jan 3 12:30:29 CET 2007


Your mapping seems to be OK, I've done something similar (with the 
url-pattern "/opencms/*" though).

I had one issue (back in the 6.0.x days, haven't checked if behaviour 
has changed since then). In case OpenCms throws an exception for some 
reason, it would use the printwriter rather than the outputstream, so 
when my filter was about to fiddle with the result returned by OpenCms 
it would not find a valid outputstream, so I had to take that into 
account. But other than that there is nothing special about writing a 
filter for OpenCms (unless of course you need to interact with OpenCms 
beyond manipulating requests or responses)

Lubomir Kovac wrote:
> Hi,
> 
> I have created an javax.servlet.Filter in my module. I have created the 
> Filter class, loaded to OpenCMS, published it as usually . I have 
> registered this filter class to opencms web.xml as I usually do with web 
> application. I have restarted the web server (Tomcat 5.5) but the only 
> answer was:
> 
> 
>      A server error occured!
> 
> 
>        Server error 500
> 
> 
>      Internal Server Error
> 
> The server encountered an unexpected condition which prevented it from 
> fulfilling the request.
> 
> The server cannot complete the request because it encountered an error.
> 
> Please try it again in a few minutes, or contact the server administrator.
> 
> Powered by OpenCms - the open source content management system 
> <http://www.opencms.org>
> 
> 
> My class name is: cz.zcu.fav.FavLoadFilter.java
> 
> web.xml mapping I have added:
>    <filter>
>        <filter-name>FavLoadFilter</filter-name>
>        <filter-class>cz.zcu.fav.filter.FavLoadFilter</filter-class>
>    </filter>
>    <filter-mapping>
>         <filter-name>FavLoadFilter</filter-name>
>         <url-pattern>/*</url-pattern>
>    </filter-mapping>
> 
> 
> 1. Whats wrong?
> 2. Do I have to register it somewhere else?
> 3. When I export the module, how this filter setting will be exported? 
> Does the importer needs to do some correction itself?
> 4. Is there any other way, how to work with filters? Or does something 
> similar exist in OpenCMS?
> 
> I was looking around and didn't find a thing.
> 
> thanks for ideas
> 
> kovi :-).
> 
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev
> 

-- 
Claus Priisholm, CodeDroids ApS
Phone: +45 48 22 46 46
cpr (you know what) codedroids.com - http://www.codedroids.com
cpr (you know what) interlet.dk - http://www.interlet.dk
--
Javadocs and other OpenCms stuff: 
http://www.codedroids.com/community/opencms



More information about the opencms-dev mailing list