1

Can I add X-Frame-Options header to a JavaScript file served through Tomcat? I am adding the header to all jsps programmatically.

Kalyan Maddu
  • 4,123
  • 2
  • 21
  • 26

1 Answers1

0

A hack (but it'll solve your problem cleanly) is to serve the .js file as a JSP. Literally rename yourfile.js to yourfile.jsp, then change the script-src that loads it into your page. Any modern browser (I've checked, and used this solution in production environments) will load a .jsp file via script-src. I did this for the same reason you are: being able to set response headers on .js files.

Steve Schneider
  • 392
  • 2
  • 5