Originally posted by kapil munjal: API specs give you the correct way of doing things.
The API specs only tells you what you should do. However,it does not give any explanation on why you should do it this way. That is why I asked what is the implication if you get the printwriter first before you set the content type. If it does not give out any error then what is the problem. Could it be that the behaviour is non-deterministic?
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.
SCJP 1.4, SCWCD 1.4
Now I am super curious what sports would be like if we allowed drugs and tiny ads.
a bit of art, as a gift, that will fit in a stocking