All Articles

GateIn – Getting HttpServletRequest from PortletRequest

A code snippet showing getting HttpServletRequest from PortletRequest in jBoss Portal

/**
 * @author Sachin Handiekar
 **/
final class Util {
	static final HttpServletRequest getOriginalRequest(PortletRequest request) {
		try {
			Method getRealRequestMethod = request.getClass().getMethod("getRealRequest");
			HttpServletRequestWrapper originalRequest = (HttpServletRequestWrapper) getRealRequestMethod.invoke(request);
			return originalRequest;
		} catch (Exception e) {
			throw new IllegalStateException("An error occurred while getting the HttpServletRequest.", e);
		}
	}
}