cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieve HTTP status code of response while processing portal component

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

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/HttpServ...

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

Former Member
0 Kudos

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