Re: servlet project setup in Eclipse
- From: Chris Smith <cdsmith@xxxxxxx>
- Date: Mon, 11 Jul 2005 07:45:46 -0600
<rosasco@xxxxxxxxx> wrote:
> It seems to assume you know Eclipse and Tomcat however because it says
> nothing about where to create HelloWorldServlet.java. Should this be
> in the workspace in the WEB-INF/src folder or elsewhere ?
The way I set up Eclipse for web application projects is this. I
configure WEB-INF/src as a source folder for the project, and WEB-
INF/classes as the output folder for the project. I then add a Context
element to Tomcat's conf/server.xml file to run the web application in-
place right from Eclipse's project directory. See the Tomcat
documentation for all the attributes of Context. This eliminates any
deployment step, allowing you to test your application in-place.
> For Tomcat, I thought there was supposed to be a servlet directory
> underneath webapps but I don't see one.
No, there isn't supposed to be a servlet directory underneath webapps.
If you follow my advice here, you need not even bother with the webapps
directory at all.
> And last, I assume the Tomcat does the compilation of the servlet
> rather than Eclipse. At any rate, how does Tomcat access the file
> HelloWorldServlet.java. Does it look into the Eclipse workspace or
> does Eclipse copy the .java and/or the .class file into the Tomcat
> server installation directory (under webapps or other??).
Eclipse does the compiling. Note that Tomcat *would* try to compile if
it could find the source files. You don't want that, because it's
confusing and wasteful for both Eclipse AND Tomcat to be compiling your
servlets. The entire reason for using a separate source folder called
WEB-INF/src, as opposed to putting the source into WEB-INF/classes, is
to keep the source isolated and prevent Tomcat from doing its magic
auto-compile stuff.
Tomcat knows to look into Eclipse's workspace because of the path you
gave it while editing server.xml as I explained above.
Another useful thing to do is install Sysdeo's Tomcat plugin for
Eclipse. That allows you to start Tomcat under Eclipse's debugger and
set breakpoints in servlet code, plus it uses the debugger hot-plug
functionality to push new code out to the server without restarting the
web application, when you make changes (although it occasionally fails
and you do have to restart).
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
.
- References:
- servlet project setup in Eclipse
- From: rosasco
- servlet project setup in Eclipse
- Prev by Date: Reposition images with mouse
- Next by Date: Re: servlet project setup in Eclipse
- Previous by thread: Re: servlet project setup in Eclipse
- Next by thread: Misusing servlets
- Index(es):
Relevant Pages
|