narma
narma

Reputation: 1

How to get HttpServletResponse from liferay portal without using PortalUtil.getHttpServletResponse

We are using endeca portlet and I want to know how to get HttpServletResponse from liferay portal action response without using PortalUtil.getHttpServletResponse method.

Upvotes: 0

Views: 505

Answers (1)

Olaf Kock
Olaf Kock

Reputation: 48057

The direct answer to your question is: Look up how Liferay implements the underlying method. You'll have to duplicate that code - potentially duplicating a few classes that are not available to applications.

The indirect nonanswer is: I doubt that there's anything meaningful that you can do with the HttpServletResponse other than messing things up: Liferay might have already written some content to it when you get hold of it. Thus you can't rely on HTTP-headers being included (reproducibly). Heck, you don't even know if your portlet is delivered through Ajax or embedded in the page anyways.

Go with the nonanswer. Unless you come up with a sensible underlying problem, I'd strongly advise against doing so (I'd even strongly advise doing so if you'd just used PortalUtil). In most cases that access to HttpServletRequest is attempted, it's a hack. On HttpServletResponse I can't even come up with something that'd be hackable that way.

Upvotes: 3

Related Questions