Skip to Content
avatar image
Former Member

Retrieve HTTP status code of response while processing portal component

Hello,

I need to retrieve the HTTP status code of a response in an AbstractPortalComponent.

So far I have identified, that the doContent() method offers with the response parameter object (IPortalComponentResponse) a method named response.getStatus(). However this always returns the value 0.

Example:

public void doContent(IPortalComponentRequest request, IPortalComponentResponse response) {
    int statusCode = response.getStatus(); //Always returns 0
}

I would have expected for example something like 200 (for status OK) or 302 (for status moved permanently).

So far I haven’t found any way to retrieve this HTTP status code. Does anyone have a clue or idea?

Best regards

Mario

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Jul 12, 2017 at 05:59 PM

    Dear Mario Liggiu,

    add servlet.jar file which you can find in library files of nwds7.3 to buildpath of abstract portal component project.

    add the following code in the docontent method of abstract portal component.

    request.getServletResponse(false).getStatus();

    Thanks and Regards,

    Kamal

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 25, 2017 at 10:19 AM

    Hello Kamal,

    thanks for your feedback.

    I have checked your suggestion. The method getServletResponse() returns a object of type HttpServletResponse. However this object does not have any method getStatus().

    As of servlet version 2.5, the method getStatus() ist not available with HttpServletResponse. For details see:

    http://geronimo.apache.org/maven/specs/geronimo-servlet_2.5_spec/apidocs/javax/servlet/http/HttpServletResponse.html

    We use at the moment SAP NetWeaver release 7.4, which seems to use servlet version 2.5.

    However, as of servlet version 3.0, the method is available:

    https://tomcat.apache.org/tomcat-7.0-doc/servletapi/javax/servlet/http/HttpServletResponse.html

    Probably future release of SAP NetWeaver will implement this version.

    Best regards

    Mario

    Add comment
    10|10000 characters needed characters exceeded