0

Is it possible to either pack only html, css and JS files in jar (no java binaries) which would then be packed into war for deployment to Tomcat?

or

Can I pack html, css, js files (no java classes) into a zip and pack it into a war for deployment to Tomcat? With this option, would Tomcat unpack the zip as needed?

Stewart
  • 17,616
  • 8
  • 52
  • 80
user1082748
  • 365
  • 1
  • 7
  • 18
  • yes, this is possible, but not recommended. it is just for doing tests. – Mimouni Oct 27 '15 at 10:19
  • which of the two options is best for a production environment. I tried packaging just html, js and css in a jar with no binaries using the jar command and through Eclipse and neither of these methods worked. The situation is that I have to package rest apis in one jar and I have a ui in html , etc that is a separate project but both must run from same war in tomcat – user1082748 Oct 27 '15 at 12:40
  • take a look here : http://stackoverflow.com/questions/7218506/eclipse-package-multiple-projects-into-one-jar – Mimouni Oct 27 '15 at 14:01

1 Answers1

1

If you are deploying to Tomcat (and there is presumably some java or JSP code associated with this) then you should use a .war file.

To incorporate purely web assets into the building of a .war, then you need to use an "overlay". There are various Maven plugins and Ant tools which do specifically this.

However, one other possible consideration, is to deploy your web assets directly to your HTTP server (ie. Apache) and then configure it to serve /css/*, /js/*, etc, from there, and every other request can be forwarded to Tomcat.

Stewart
  • 17,616
  • 8
  • 52
  • 80