Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Bryan Young
Adding a Servlet Filter
January 7, 2008 7:56 AM
Answer

Bryan Young

Rank: New Member

Posts: 1

Join Date: January 4, 2008

Recent Posts

I am trying to add a servlet filter to our portal. I would like to intercept all calls to the portlet to monitor user activity. When I add the filter to our web.xml it applies to resources only (css, js, images), and not to portlet calls themselves.

In retrospect this makes sense. The web.xml is describing the web app we created; it does not add anything to the Liferay webapp iteself. I assume there is some simple way to configure the servlet filter to work the way I expect. Any suggestions?
Ray Augé
Re: [Liferay Forums][3. Development]Adding a Servlet Filter
January 7, 2008 8:20 AM
Answer

Ray Augé

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1195

Join Date: February 7, 2005

Recent Posts

> I am trying to add a servlet filter to our portal. I would like to intercept all calls to the portlet to monitor user activity. When I add the filter to our web.xml it applies to resources only (css, js, images), and not to portlet calls themselves.
>
> In retrospect this makes sense. The web.xml is describing the web app we created; it does not add anything to the Liferay webapp iteself. I assume there is some simple way to configure the servlet filter to work the way I expect. Any suggestions?

You'd have to add the filter in the Liferay web.xml file... the reason
being that the filter mappings have to apply to paths mapped in the same
context... and this can never happen from another war.

So, you could bundle you custom filter code in a jar, include it in the
portal's WEB-INF/lib and then configure the portal's WEB-INF/web.xml
with the custom filter, and apply it to the paths you want want
monitored... e.g. "/*"
Paul Hussein
RE: Re: [Liferay Forums][3. Development]Adding a Servlet Filter
September 16, 2010 3:00 AM
Answer

Paul Hussein

Rank: Junior Member

Posts: 63

Join Date: May 30, 2006

Recent Posts

So there is definately no way of doing this from a Hook then as you have to manually add a filter to the web.xml