I have some code that looks like this:
public class EGOChervonAPIMethods extends HttpServlet
{
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
initalization code
big case statement
response.addHeader("Access-Control-Allow-Origin", originHeader);
response.addHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Referer, User-Agent");
}
And the headers sometimes get added sometime they do not. I can step through the code and it does execute. Like it should since it is at the very end of the code not if there. And no exceptions triggered. I even checked with a call to response.containsHeader
.
If I change this to be:
public class EGOChervonAPIMethods extends HttpServlet
{
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
initalization code
response.addHeader("Access-Control-Allow-Origin", originHeader);
response.addHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Referer, User-Agent");
big case statement
}
It works. clearly something happens in the big case statement. But as far as I can see the code is identical. Only a few calls to response.getWriter().println
are different.
What else could it be?