cancel
Showing results for 
Search instead for 
Did you mean: 

Add HTTP response header

cand1
Advisor
Advisor
0 Kudos

Hi all,

I need to add a response header from a web application which works fine when I deploy the app to Tomact for instance, but when I deploy it on WebAS is looks like the response is filtering out the response header somehow.

I haven't found any configuration parameter in the HTTP provider service yet to disable the supression.

Does anybody have an idea?

Thanks

Daniel

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi All,

We has a short debugging session yesterday with Daniel and it turned out that indeed a third party component was flushing the response before Daniel's setHeader call. Hence the header was never delivered to the client.

Greetings, Myriana

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Daniel,

I don't think there is some mechanism that removes the header on purpose. As for the http trace you can see the requests/responses in dispatcher\log\services\http\req-resp.trc or was this not what you were referring to ?

I guess it will be faster if you send me the trace from the server and dispatcher default traces when the problem happens via email

Regards, Myriana

Former Member
0 Kudos

Hi Daniel,

This is really strange, as usually there should be no component between the server and dispatcher and whatever is written by LogRequestResponseHeader should also be seen in the dispatcher http traces.

What is the actual header that you want to set? It might have a special handling in the j2ee engine web container.

Have you tried the webcontainer trace i suggested previously, if you increase the web container TraceLevel property to one and then the log locations for response to Debug you should be able to see by searching about the header in default traces and the corresponding stack trace which is the component that removes it.

Regards, Myriana

cand1
Advisor
Advisor
0 Kudos

Hi Myriana,

I activated the webcontainer now and found the following message:

Message : java.lang.Exception: client [11776] HttpServletResponseFacade.setHeader [204578] in application [my_app]: name = [MY_HEADER], value = [4711], isIncluded = [false], committed = [true]

It looks like the header is set and this is what I also see in the server HTTP provider response file.

Is there some kind of response header filtering, compression, clean-up ...?

Thanks,

Daniel

cand1
Advisor
Advisor
0 Kudos

Hi Myriana,

is there a way to enable the http dispatcher debug to see what going wrong? I added a log controller according to

http://help.sap.com/saphelp_nw04/helpdata/en/8e/af3442d692ae04e10000000a1550b0/content.htm

but I can't find the debug info. To which defaulttrace file it is written?

Thanks

Daniel

Former Member
0 Kudos

From earlier experience I know that there is some difference in when the servlet container allows headers to be written to the HTTP response. In general, if the response is allready partly sent to the user then such a call is usually just ignored or throws an exception.

Where in the code do you set the HTTP response header ?

Is there anything you can do to ensure that nothing is written out before that ?

Regards

Dagfinn

0 Kudos

Hi Daniel,

Judging by the exception, Dagfinn is right. This kind of exception happens when the Web Container has already send part of the response. This could happen automatically if the response buffer is exceeded. Then the Web Container flushes the current content of the response. Afterwards you cannot set any header. The other case would be if some of the components that generate the response (of your web application) my flush the response explicitly.

Check you case, maybe you can set the header much earlier.

Regards,

Diyan

Former Member
0 Kudos

Hi Daniel,

Is this a regular j2ee application? If yes then you should have no problem setting a response header from you application.

Do you get any error or the header is just missing?

You can try tracing the webcontainer components as described in note 825797 to see if the header is really reset.

If it is by another component then i guess doing the header setting from a filter component should do the trick.

Greetings, Myriana

cand1
Advisor
Advisor
0 Kudos

Hi Myriana,

thanks for your answer.

Indeed, it is a regular web application, but with a bunch of integrated 3rd party libraries. Usually, it's not a problem to set the response header. In Tomcat it works fine, I see the header with IE plugin HttpWatch for instance.

I turned on the header tracing of the HTTP provider service in both dispatcher (HttpTrace=enableHeaders) and server (LogRequestResponseHeaders=true) and found that the server tracing contains the header but not the dispatcher trace file.

It looks like a component in between removes this header.

Any ideas?

Thanks

Daniel