Remove HTTP Response headers in Java

Is there a way to remove HTTP response headers like Server and X-Powered-By?

My application is using a Weblogic server. I'm programming in Java using the Spring MVC framework and Hibernate, and using JSP for views.


Depends on where the headers are added. If inside your app, you can use a Spring MVC Interceptor to remove them after your controller calls. If outside your app, you might be able to try a Java EE filter configured in web.xml (the example is security, but the approach will also work for your use case). If its added after that, you may want to look at your web front end (Apache, IIS, what-have-you) to configure a filter there.


This answer describes an approach for removing specific headers, as the HttpServletResponse interface does not allow for header removal explicitly. You will need some trial and error to determine what portion of your stack is adding the header.

Need Your Help

Does insertion to STL map invalidate other existing iterator?

c++ stl

I used std::map in STL. Can I use iterator after some other element inserted to the map? Is it still valid?

Behaviour of ruby with regards to numerical exactness (Scheme comparison)

ruby lisp scheme

In Ruby (1.9), are numbers always considered exact? I know Ruby does some fairly complex stuff with numbers under the hood, since you can do crazy things like ask for 1 trillion to the power of 1

Handling AccessViolation exception in try catch c#

wpf mvvm c#-4.0 try-catch

How to catch the AccessViolation exception in try-catch block: