Thats right..API doesn't give you this Idea "why this approach".
The API always describe things in a very easy and appropriate manner.
If in this example, when we are setting the contentType first and then creating an object of printwrite, it means that whatever we are going to write has been instructed to the container by this command. And then creating the object for writing the content in the response.
response.setContentType("text/html");
PrintWrite out = response.getWriter();
But if we create the object for writing to the response and set the contentType to app/jar. Then writer object is and overhead for the
servlet.
Well, there is no way, it is going to give some error but definitely this approach doesn't look right.