• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can we protect css, js files with out being publicly accessible ?

 
Rajani Gummadi
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

I started a small sturts based application and was using a css file. Though tutorial, mentioned to keep the css file at application level, I experimented putting it under WEB-INF, though I was skeptical. As expected, css file is not accessible as browser would not be served those restricted files by the container. But that leaves me a question, on how to protect css or js files which are used by browser, if I can not keep them in WEB-INF. Keeping the point of protecting those resources aside, but how to do that, if we have to ? Can some body explain me this ?

Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't. If the browser can get at the files -- and it must, that's how HTTP/HTML works -- then anyone can. If you hide them, then the browser no longer has access either.

I can almost understand wanting to hide the JavaScript (maybe), but who cares about the CSS?

If you are really concerned about the script, you can pack or minimize it which adds a level of obfuscation.
 
Rajani Gummadi
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear,

I do agree that protecting css is not adding any value, as hardly any body would care. But coming to javascript, what do you mean by packing and how do we do that ?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic