Forums

Home » Liferay Portal » English » 3. Development »

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Bruchez Erik
Issues with PortletFilter and forwards/includes
August 27, 2010 9:00 AM
Answer

Bruchez Erik

Rank: New Member

Posts: 2

Join Date: August 9, 2010

Recent Posts

All,

I am writing a portlet filter:
MyFilter implements RenderFilter  { ... }


First issue: within the filter, I want to intercept the output of:

filterChain.doFilter()


So I pass dofilter() an instance of RenderResponseWrapper:

filterChain.doFilter(renderRequest, myRenderResponseWrapper)


Here is the first problem. If my filter applies to a portlet that just writes content out, I am able to intercept the output.

However, if my filter applies to a portlet that forwards or includes a JSP, no method of my RenderResponseWrapper is called, except maybe getResponse().

This seems wrong: it seems that whatever way the filtered portlet decide to produce its output, it shouldn't bypass the filter. Or did I miss something?

Second, still within the filter, in the case where I obtain content, I want to forward or include the request further to a servlet.

So I do:

dispatcher = portletContext.getRequestDispatcher("/foobar")


then:

dispatcher.forward(renderRequest, myRenderResponseWrapper2)


Same issue here: no method is called on myRenderResponseWrapper2, and I cannot intercept the output produced by my servlet.

So in both cases, it seems that whenever there is an include or forward anywhere within filtered resources, those bypass the response object that is passed.

Now my expectation was that this should work. Is this a bug, a feature, or am I doing something wrong?

-Erik
Andre Deer
RE: Issues with PortletFilter and forwards/includes
March 10, 2011 7:42 AM
Answer

Andre Deer

Rank: New Member

Posts: 1

Join Date: March 10, 2011

Recent Posts

I haven't seen any further posts on this thread and wondered if you resolved the issue, or it still stands? Thanks vm -- Andre


Bruchez Erik:
All,

I am writing a portlet filter:
MyFilter implements RenderFilter  { ... }


First issue: within the filter, I want to intercept the output of:

filterChain.doFilter()


So I pass dofilter() an instance of RenderResponseWrapper:

filterChain.doFilter(renderRequest, myRenderResponseWrapper)


Here is the first problem. If my filter applies to a portlet that just writes content out, I am able to intercept the output.

However, if my filter applies to a portlet that forwards or includes a JSP, no method of my RenderResponseWrapper is called, except maybe getResponse().

This seems wrong: it seems that whatever way the filtered portlet decide to produce its output, it shouldn't bypass the filter. Or did I miss something?

Second, still within the filter, in the case where I obtain content, I want to forward or include the request further to a servlet.

So I do:

dispatcher = portletContext.getRequestDispatcher("/foobar")


then:

dispatcher.forward(renderRequest, myRenderResponseWrapper2)


Same issue here: no method is called on myRenderResponseWrapper2, and I cannot intercept the output produced by my servlet.

So in both cases, it seems that whenever there is an include or forward anywhere within filtered resources, those bypass the response object that is passed.

Now my expectation was that this should work. Is this a bug, a feature, or am I doing something wrong?

-Erik
Michael Young
RE: Issues with PortletFilter and forwards/includes
May 18, 2011 11:45 AM
Answer

Michael Young

LIFERAY STAFF

Rank: Liferay Master

Posts: 833

Join Date: August 4, 2004

Recent Posts

This issue has been fixed. See http://issues.liferay.com/browse/LPS-17363