[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.newcomer] Re: Adding servlet to existing project

Udo Hoerhold schrieb:
Hi,

I've been using Eclipse with existing projects by creating a simple project, then linking the existing source folders in my file system to folders in my workspace. This has worked so far since I don't have to move the existing source, which is in a source control directory structure.

Now I'm trying to add a servlet to the project, and I'd like to use one of the wizards to create some of the resources, like descriptors, etc. The servlet will have dependencies to classes in the rest of the project. Is there any easy way to do this? The servlet wizard won't come up at all, since it's not a web project. I don't want to have to move the entire existing project (it's very large) over to a new web project. Can I create a new web project just for the servlet, and get it to use the classes from the main project? Can someone give me some tips on doing this? I've tried looking through the documentation, but I don't see this kind of situation addressed anywhere.

Thanks.


1.
Import everything Tomcat (or any other Servlet container) exposes to web applications (this means everything in common/lib and shared/lib) as libraries into your application (this can be done in the project properties under Java). Create a new class that extends javax.servlet.http.HttpServlet as your Servlet. Add the Servlet to your web descriptor (web.xml).


2.
Create a new Dynamic Web Project and check your existing project as dependency in project properties under Java. Then create your Servlet in the new web project with the wizard.


Because you already have a web project in Eclipse I would prefer the first.

Kind regards,
Daniel