Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » Can one make one servlet's code visible/accessible to an other?
Can one make one servlet's code visible/accessible to an other? [message #188897] Thu, 01 March 2007 10:16 Go to next message
Michael Moser is currently offline Michael Moser
Messages: 914
Registered: July 2009
Senior Member
Sorry for this maybe stupid question - I am not an expert in Servlet
configuration (probably eclipse WTP made everything just too simple so
far) but now I hit a config problem that I was unable to solve so far.

I have a servlet 1 which (re-)uses some code developed for another
servlet 2, i.e. it directly accesses some API classes within that
servlet. For simplicity I just imported that other servlet as another
project and referenced it in eclipse. That allowed me to access all
required classes of that other servlet (access for compilation purposes
that is).

Now, when I deploy these two projects as seperate servlets, I get of
course problems, because servlet 1 can not simply access the classes nor
the classpath of servlet 2. It's really only an access question: for
test purposes I simply copied the code from both servlets into a single
project and then things deploy and run fine. But I would like to keep
the two servlets distinct, while simply allowing servlet 1 to access
everything in servlet 2. Is that possible?

To make it precise: I don't even care whether servlet 1 actually
accesses the very same instance of servlet 2 or whether it just gets
access to the classpath and then recreates a second instance of those
classes. In my case that wouldn't make a difference.

Hope I could make myself clear...

Michael

PS.: This is on Tomcat v5.5. Tools are eclipse v3.3M5 and WTP v2.0M5.
Re: Can one make one servlet's code visible/accessible to an other? [message #188914 is a reply to message #188897] Thu, 01 March 2007 12:44 Go to previous message
Eclipse User
Originally posted by: kosta.bea.com

You can try creating a J2EE Utility project and putting servlet 2 into
it. You can then have a web project that contains servlet 1 reference
the utility project by using the J2EE Modules Dependencies property page
on the web project. That will setup a structure such that the contents
of the utility project will be jarred up and placed into the web app's
WEB-INF/lib directory at deployment time. This has the affect of putting
both of the servlets in the web app's classloader at runtime. Note that
you will have to manually add a servlet declaration for servlet 2 in web
project's web.xml file and this approach only works for classes. It
doesn't work for re-using jsp files or other web resources.

- Konstantin
Previous Topic:validation of ccxml
Next Topic:example of the editor configuration extension point usage?
Goto Forum:
  


Current Time: Wed Apr 16 00:29:11 EDT 2014

Powered by FUDForum. Page generated in 3.18438 seconds