Share resources in Java web app

116 Views Asked by At

I have a Java web app. Over time it has evolved in to what should really be two apps. There are things like CSS and Javacript files though that both ill need. Is there a way to have them shared so I do not need to duplicate these files.

Here is some additonal info:

Java 1.7 Using JSF running in Glassfish 4

2

There are 2 best solutions below

0
On

If you refactor to 2 web projects say Web1 & Web2, make one of them base Web say Web1 and have other Web2 reference Web1, so you dont have to duplicate and keep them separate as well.

But unless you have a strong reason to split out 2 web projects, its advisable to keep it one if you have shared resources since a lot of shared resources like DB connection objects, services could be commonly pooled and will require relatively lesser resources

0
On

Perhaps the best option is to have a third web application, even in another domain (e.g. the Google Hosted Libraries), containing static resources such as CSS, JS, images, etc.

This is very convenient when the site is a huge sets of pages and different sites in the organization. Thus, if you need change to another style sheet or image, just change in one place.