Can I add X-Frame-Options header to a JavaScript file served through Tomcat? I am adding the header to all jsps programmatically.
Asked
Active
Viewed 3,027 times
1
-
possible duplicate of [Set header in Tomcat](http://stackoverflow.com/questions/16296145/set-header-in-tomcat) – Quentin Jan 29 '14 at 15:45
-
2That header has no effect on JS files. – SLaks Jan 29 '14 at 15:46
1 Answers
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