-1

I have Freemarker template and I wish to share it between my Java Servlets packed to a separate WAR's.

What is the correct place for such a common templates? I use Apache Tomcat 7 and I don't want to put all of them to /var/lib/tomcat7

This question is NOT about how to share application code and where to put JAR files or how to use extends in Java. It is even NOT about how to share web.xml.

The question is how to share common templates and where is a right place for shared templates.

1 Answers1

1

Depends on why is this needed. One possibility is putting the templates into a Maven artifact that both war-s depend on (possibly transitively). Then you can use ClassTemplateLoader to access them. Another possibility is having an application home directory somewhere, like /var/lib/myapp, and then have a templates subdirectory in it (and later maybe some others for other shared application data). The application home directory should be specified with an environment variable or Java System property, so it can be decided by those who install the application, and the application can read what it is. Then in the war-s you could use FileTemplateLoader to load the templates.

ddekany
  • 29,656
  • 4
  • 57
  • 64