Using the 'getOriginalServlet' Function to Retrieve the Default Query String in DXP 7.0

This article serves as a reference guide on how to use the getOriginalServletRequest function to get the default queryString when using the OSGi framework. Developers familiar with Liferay Portal 6.2 EE and now using DXP 7.0 (also 7.1, 7.2 or 7.3) will find that certain requests are now routed instead through OSGi.

Resolution

Use Case #1

Developers need an extra URL parameter inside a custom portlet.

Use Case #2

Developers need to add the paramName from a layout default Query String.

  1. Navigate to any site.
  2. Click the Configure Page icon at the upper right.
  3. Click the Advanced tab.
  4. Enter the following in the Query String field: p_p_id={portlet name}&_{portlet name}_paramName=paramValue
  5. Click the Save button.

Prior to the fix for LPS-56630, the command getOriginalServletRequest would stop once any non-Liferay request wrapper was encountered; this meant that it would preserve the last servlet request created by the internal forward performed by the application server.

However, in order to fix LPS-56630 caused by moving some processing into OSGi, it was discovered that all of the HttpServletRequestWrappers need to be "unwrapped". These had been added by OSGi when the request was routed through OSGi.

This fix resulted in not only unwrapping the ones added by OSGi, but also the ones added by the application server as well.

As an example of how this works, see the revamped Nested Portlets portlet. The sample shows how to stop the unraveling process as it transitions from a regular request to a forwarded request.

See the source on GitHub: Nested Portlets.

Additional Information

¿Fue útil este artículo?
Usuarios a los que les pareció útil: 0 de 0