I want to add some plain text and two headers to the HttpServletResponse, the code is the following:
resp.setContentType("text/plain");
resp.getWriter().write(messages.get(next).getContent());
resp.addHeader("success", "yes");
resp.addHeader("hasnext", ((Boolean)hasNext).toString());
The problem I encounter is that sending the content prevents the sending of the headers. If I don’t write the content the headers are received fine, if I include the text they don’t.
What is the problem ?
Try setting your headers first. Also I’m assuming you call
writer.flush()after you are done with your response.UPDATE
Can you check if the following works:
Use
curl -i http://yourapp.appspot.comto verify the headers.