Re: servlet project setup in Eclipse



<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
.



Relevant Pages

  • Re: [ant] "build-Design"
    ... Wenn Eclipse P compiliert, weiss Eclipse zwar, ... der Eclipse-spezifischen Builddatei die normale Builddatei aufrufe. ... Wie führst Du sinnvoll UnitTests auf dem Tomcat aus? ... JPDA = Java Platform Debugger Architecture ...
    (de.comp.lang.java)
  • Re: servlet project setup in Eclipse
    ... It seems to assume you know Eclipse and Tomcat however because it says ... I thought there was supposed to be a servlet directory ... underneath webapps but I don't see one. ...
    (comp.lang.java.help)
  • servlet project setup in Eclipse
    ... I'm following a tutorial on using Struts with Eclipse. ... servlet in the browser at localhost:8080/servlet/HelloWorldServlet. ... It seems to assume you know Eclipse and Tomcat however because it says ... underneath webapps but I don't see one. ...
    (comp.lang.java.help)
  • Re: Limiting Disck Cache
    ... What else are you running besides Tomcat and Eclipse? ... RAM and what goes in swap sees this brand new file being used ... that one file takes up all of cache. ...
    (Debian-User)
  • Re: My java changes not reflecting on server due to dependency
    ... I am mainly working on turboLister, but I have some changes to be made ... I have build automatically enabled in my eclipse, ... but not those i made in the biz project. ... The second is partly an Eclipse question because you're using the Eclipse-managed Tomcat instance, but the larger question is all Tomcat. ...
    (comp.lang.java.programmer)