Multiple WebContent directories in a single eclipse dymanic web project

2.8k Views Asked by At

I have an existing project that I'm trying to convert correctly into an Eclipse Dynamic Web Project. I've mostly got it working, however there is on issue that I'm not sure how to fix.

The project has something like 2 modules that share the same Java classes, but need to be deployed as separate webapps into the app server (Tomcat 5.5). So the folder structure is something like

/Webcontent_root
----/app1
    ..../WEB-INF etc...
----/app2
    ..../WEB-INF etc...

Is this something that can be controlled within eclipse?

Thanks

3

There are 3 best solutions below

3
On BEST ANSWER

I guess, eclipse can't control project with more than one context.

Approach I.

I think you should create three projects: regular java project with classes, one dynamic web project for first webcontent and one for second. Than tune up "Java Build Path" and "Deployment Assembly" settings.

Approach II.

Or you can create two web projects, first with classes and webcontent, second with webcontent and link to first project ("Java Build Path" and "Deployment Assembly" settings).

0
On

Create 2 web project and 1 java project for the shared java source. Both web project can use the shared project as a jar file in their web-inf/lib

As @Nantipov says, use the deployment assembly screen to make web projects get the shared java project as a jar in the library filder.

0
On

Yes, it can--just not with the UI in WTP (deployment has always been a sore spot and ongoing effort to improve). The .settings/org.eclipse.wst.common.component in your project controls what Eclipse/WTP thinks of as web content root(s) in your project. Odds are you just need to create a new folder in the project and add it as a sibling to the existing element in that file, but with a correct source-path value.