Ajay Ajay - 4 years ago 226
Java Question

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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download