4

I am handling HTTP header 'Content-Language' for multi languages. I have 2 ways:

  1. WAY1:

     // setHeader
     response.setHeader("Content-Language", "en, fr"); // Using ',' as seperator
    
  2. WAY2:

     // addHeader ----- Not setHeader
    
     response.addHeader("Content-Language", "en");
     response.addHeader("Content-Language", "fr");
    

My question is: Are these two ways equivalent? Which one should be used?

Thank you!

1 Answer 1

8

You can use both variants. In both cases a response header Content-Language: en, fr will be sent.

Calling response.addHeader multiple times for the same header name produces a concatenated version of the header values separated by a ", ".

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.