0

In IBM Websphere Portal 8.5, how can I get retrieve query string parameters from the URL, inside a JSR286 portlet ?

It seems that the HTTPServletRequest is not passed through to the PortletRequest. Do I need to use the configuration in the portlet.xml ? That seems to be used to manage communication between portlets, but anyway I've tried to use it but without success, every ParameterNames and ParameterMap is coming empty.

Do I need to set some interceptor/filter to pre-process the parameters ?

Not sure how much of this question is specific about IBM Websphere Portal or just plain JSR286 portlets.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
spnbldk
  • 97
  • 1
  • 3
  • 10

3 Answers3

0

Using just the portlet spec, I don't believe there is anyway to get access to the HttpRequest. The idea behind that is that since the portlet doesn't have full control over the entire HTTP Request / Response (the portlet container does), the portlet shouldn't be able to have access to those objects.

IBM Portal does have an API you can call to get to it though should you need it for scenarios like yours. Here is an abbreviated code sample from one my projects that we run on Portal 8.0. Double check the docs for if the API changed in 8.5.

import com.ibm.wps.pb.utils.portlet.PortletUtils;

...

public void doView(RenderRequest request, RenderResponse response) {

    HttpServletRequest httpRequest = PortletUtils.getHttpServletRequest(request)
}
Nick Roth
  • 3,057
  • 2
  • 15
  • 15
  • Hi. Thanks for the input. I'm not being able to find that class. Is there a maven source for it or do I have to manually install it from the Portal libs ? – spnbldk Dec 15 '14 at 16:02
  • I don't think there is a publicly available Maven repo that will have the class. You should be able to get a copy of the JAR from your Portal install and add it to your Maven dependencies using as a local JAR. I didn't setup the Maven build on this project so I unfortunately don't have much more info for you at the moment. – Nick Roth Dec 15 '14 at 19:15
0

Try (Another option):

import com.ibm.ws.portletcontainer.portlet.PortletUtils;

public HttpServletRequest getHttpServletRequest(PortletRequest request) {
        return PortletUtils.getHttpServletRequest(request);
    }

You must install the jar (com.ibm.ws.portletcontainer.jar) in your local maven repository.

This jar is in: WebSphere / AppServer / plugins

andymrg
  • 204
  • 4
  • 14
0

be careful when working with primefaces bridge, which gives us the method PortletUtils.getHttpServletRequest is an object of type RenderRequestWrapper, so there are q do the following:

HttpServletRequest requestInsideThePortlet = PortletUtils
.getHttpServletRequest (((RenderRequestWrapper) PortletRequest)
.getPortletRequest ());

with this we get the HttpServletRequest and not null :)