IBM Support

Unable to access the HttpServletRequest headers value before rendering JSP page in Faces Portlets

Troubleshooting


Problem

While attempting to access HttpServletRequest header value (such as "serviceID") in Faces Portlets before the JSP page is rendered, this value is not available and a null pointer is thrown. This technote explains how to get access to header value(s) before rendering the JSP page with a simple workaround.

Symptom

While attempting to access HttpServletRequest header value (such as "serviceID") in Faces Portlets before the JSP page is rendered, this value is not available and a null pointer is thrown; however this value is accessible after the JSP page is rendered, so if you attempt to access this header value within the JSP page, it will be available, but when you have the same code within your PageCode file to access the value (such as "serviceID"), the header value is not available as the code is invoked and executed before the JSP page is rendered.

As noted in the JSF API documentation, getRequestHeaderMap() should be able to accomplish the task. However, the Portlet bridge implementation in Rational Application Developer for WebSphere Software 7007 fails to do so.

Cause

This is a known issue in Rational Application Developer for WebSphere Software 7.0.0.7 in that JSF's ExternalContext class is not able to manage this.

Environment

Rational Application Developer for WebSphere Software 7.0.0.7
Websphere Portal Server v6.1

Note: The following Portlet projects and Portlet types are supported for creation and publishing on IBM Portal Server v6.1 in Rational Application Developer for WebSphere Software 7.0.0.7. For more detailed information about Rational Application Developer for WebSphere Software 7.0.0.7 features & enhancements, review the links provided in "Related Information" section :

  • Portlet projects
    • IBM
    • JSR 168
  • Portlet types
    • Faces
    • Basic
    • Struts
    • Empty
Portal projects are NOT supported for Portal Server v6.1 in Rational Application Developer for WebSphere Software 7.0.0.7.

Resolving The Problem

As documented within the JSF API specifications, JSF's ExternalContext class should be able to manage this, however, this was not the case with the Portlet bridge implementation in 7007.

Example:

Consider the following piece of code:

*******************************************

Map map = getFacesContext().getExternalContext().getRequestHeaderMap();

if (map != null) {

System.out.println("Map was not null");

Set es = map.entrySet();

*******************************************

When you get to map.entrySet(); it throws a null pointer so the map is not null but entry set is.

WORKAROUND:

To workaround this problem, in Portal, to access Headers you need to access Properties instead, that is use request.getProperty() of RenderRequestWrapper class.

Note: This issue has been fixed in Rational Application Developer for WebSphere Software versions 7.0.0.8 and 7.5.

[{"Product":{"code":"SSRTLW","label":"Rational Application Developer for WebSphere Software"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Portal \/ Portlet Development","Platform":[{"code":"PF033","label":"Windows"},{"code":"PF016","label":"Linux"}],"Version":"7.0;7.0.0.1;7.0.0.2;7.0.0.3;7.0.0.4;7.0.0.5;7.0.0.6;7.0.0.7","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
16 June 2018

UID

swg21328141