Disable all default HTTP error response content in Tomcat

If you do not want tomcat to show an error page, then do not use sendError(…). Instead use setStatus(…). e.g. if you want to give a 405 response, then you do response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED); response.getWriter().println(“The method ” + request.getMethod() + ” is not supported by this service.”); Also remember not to throw any Exceptions from your servlet. … Read more

jQuery – get AJAX response headers

For backward compatibility with XMLHttpRequest, a jqXHR object will expose the following properties and methods: getAllResponseHeaders() and getResponseHeader(). From the $.ajax() doc : http://api.jquery.com/jQuery.ajax/ For jQuery > 1.3 success: function(res, status, xhr) { alert(xhr.getResponseHeader(“myHeader”)); }

ASP.NET How To Stream File To User

I wouldn’t call Response.Close() or Response.End(). Response.End() will stop the page execution/rendering at that point. No code following Response.End() will be run. The response is terminated at that point with no further output added to the stream. Response.Close() is similar to Response.End(), but allows code to be executed after it is called (but no further … Read more

Execute code in Django after response has been sent to the client

The method I am going for at the moment uses a subclass of HttpResponse: from django.template import loader from django.http import HttpResponse # use custom response class to override HttpResponse.close() class LogSuccessResponse(HttpResponse): def close(self): super(LogSuccessResponse, self).close() # do whatever you want, this is the last codepoint in request handling if self.status_code == 200: print(‘HttpResponse successful: … Read more

setcookie, Cannot modify header information – headers already sent [duplicate]

The warning is clear. Warning: Cannot modify header information – headers already sent by (output started at C:\xampp\htdocs\test\index.php:9) in C:\xampp\htdocs\test\index.php on line 12 Cookies are sent in the HTTP response header. Since the HTML content already started, you cannot go back to the header and add the cookie. From http://php.net/setcookie: setcookie() defines a cookie to … Read more

Writing MemoryStream to Response Object

I had the same problem and the only solution that worked was: Response.Clear(); Response.ContentType = “Application/msword”; Response.AddHeader(“Content-Disposition”, “attachment; filename=myfile.docx”); Response.BinaryWrite(myMemoryStream.ToArray()); // myMemoryStream.WriteTo(Response.OutputStream); //works too Response.Flush(); Response.Close(); Response.End();

download csv file from web api in angular js

Try it like : File.save(csvInput, function (content) { var hiddenElement = document.createElement(‘a’); hiddenElement.href=”https://stackoverflow.com/questions/20300547/data:attachment/csv,” + encodeURI(content); hiddenElement.target=”_blank”; hiddenElement.download = ‘myFile.csv’; hiddenElement.click(); }); based on the most excellent answer in this question