Skip to content

Instantly share code, notes, and snippets.

@topolik
Created September 4, 2012 09:24
Show Gist options
  • Save topolik/3619076 to your computer and use it in GitHub Desktop.
Save topolik/3619076 to your computer and use it in GitHub Desktop.
redirect after exception from serve resource
@Override
public void serveResource(
ResourceRequest resourceRequest, ResourceResponse resourceResponse)
throws PortletException {
try {
... generate csv
... set response headers
... write csv
} catch (Exception e) {
SessionErrors.add(resourceRequest, e.getClass().getName());
// see http://issues.liferay.com/browse/LPS-13039
// if (liferay version is <= 6.1.0 GA1) {
((com.liferay.portal.kernel.portlet.LiferayPortletResponse) resourceResponse).getHttpServletResponse().setStatus(302);
// } else {
// resourceResponse.setProperty(ResourceResponse.HTTP_STATUS_CODE, "302");
// }
resourceResponse.addProperty("Location", resourceResponse.createRenderURL().toString());
return;
}
}
@Pabline
Copy link

Pabline commented Mar 28, 2016

@kalpak44
Copy link

+1

@amosfong
Copy link

Thanks! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment