(Translated by https://www.hiragana.jp/)
GitHub - nreese/StaticHeaders: Create static headers in Apache Tomcat just by editing web.xml.
Skip to content

Create static headers in Apache Tomcat just by editing web.xml.

License

Notifications You must be signed in to change notification settings

nreese/StaticHeaders

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

StaticHeaders

Create static headers in Apache Tomcat just by editing web.xml.

This project came about when trying to debug a CORS problem. Tomcat has a built in CORS filter org.apache.catalina.filters.CorsFilter but this filter has lots of internal logic that masked the problem I was trying to debug. A stack overflow question suggested building a new filter that just returned static values. I found having to write a java class, compile into byte code, and then package into a jar file a large hassel just to test a couple of headers. As a result, I created this generic filter that allows for the easy creation of headers by simply editing the web.xml file.

Usage

  • Install release jar in CATALINA_HOME/lib
  • Add filter to CATALINA_HOME/conf/web.xml
<filter>
  <filter-name>StaticHeadersFilter</filter-name>
  <filter-class>StaticHeaders</filter-class>
  <init-param>
    <param-name>hello</param-name>
    <param-value>world</param-value>
  </init-param>
</filter>
<filter-mapping>
    <filter-name>StaticHeadersFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
  • restart apache tomcat
  • test headers curl -XGET -I 'http://localhost:8080'

Build

  • Set CATALINA_HOME env
  • run make.sh

About

Create static headers in Apache Tomcat just by editing web.xml.

Resources

License

Stars

Watchers

Forks

Packages

No packages published