Skip to content
Advertisement

What is the difference between Servlet response methods addHeader and setHeader?

Can I use setHeader to set an new header?
Or Do I need to addHeader first, then use setHeader method?

Advertisement

Answer

The documentation says that you can add multiple values to a particular header using the addHeader method, whereas an initial value would be overwritten if you use the setHeader method.

In both cases a non-existent header would be created.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement